madkit.gui

## Class SwingUtil

- java.lang.Object
- - madkit.gui.SwingUtil

-     public final class SwingUtil
      extends Object

  This class provides some utilities for building swing components.
  Since:
    MaDKit 5.0.0.16
  Version:
    0.9
  Author:
    Fabien Michel

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ImageIcon` | `MADKIT_LOGO` The MaDKit's logo
    `static ImageIcon` | `MADKIT_LOGO_SMALL` The MaDKit's logo with a size of 14x14 pixels

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static AbstractButton` | `addBooleanActionTo(Container menuOrToolBar, BooleanAction action)` Creates a `JCheckBoxMenuItem` for a menu or `JToggleButton` for a tool bar
    `static void` | `addMaDKitActionsTo(Container menuOrToolBar, AbstractAgent agent)` Adds to a menu or toolbar the following actions: `KernelAction.EXIT` `KernelAction.COPY` `KernelAction.RESTART` `KernelAction.LAUNCH_NETWORK` `KernelAction.STOP_NETWORK` `GUIManagerAction.CONNECT_TO_IP` `GlobalAction.JCONSOLE` `KernelAction.CONSOLE` `GlobalAction.DEBUG` `GlobalAction.LOAD_LOCAL_DEMOS` `GlobalAction.LOAD_JAR_FILE` `GUIManagerAction.ICONIFY_ALL` `GUIManagerAction.DEICONIFY_ALL` `GUIManagerAction.KILL_AGENTS`
    `static JSlider` | `createJSlider(BoundedRangeModel model)` Creates a JSlider built using a `DefaultBoundedRangeModel` and containing a `MouseWheelListener` and some usual default settings
    `static JPanel` | `createSliderPanel(BoundedRangeModel model, String label)` Creates a labeled panel containing a slider built using an existing `DefaultBoundedRangeModel`
    `static JPanel` | `createSliderPanel(JSlider slider, String label)` Creates a labeled panel containing a slider with default size.
    `static JPanel` | `createSliderPanel(JSlider slider, String label, int width)` Creates a labeled panel containing a slider and considering a particular width
    `static void` | `scaleAllAbstractButtonIconsOf(Container container, int size)` Resizes the icons of all the abstract buttons which are contained in a container.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MADKIT_LOGO

          public static final ImageIcon MADKIT_LOGO

      The MaDKit's logo

    - #### MADKIT_LOGO_SMALL

          public static final ImageIcon MADKIT_LOGO_SMALL

      The MaDKit's logo with a size of 14x14 pixels

  - ### Method Detail

    - #### createSliderPanel

          public static JPanel createSliderPanel(JSlider slider,
                                                 String label)

      Creates a labeled panel containing a slider with default size.
      Parameters:
        `slider` -
        `label` -
      Returns:
        a panel for the slider

    - #### createSliderPanel

          public static JPanel createSliderPanel(JSlider slider,
                                                 String label,
                                                 int width)

      Creates a labeled panel containing a slider and considering a particular width
      Parameters:
        `slider` -
        `label` -
      Returns:
        a panel for the slider

    - #### createSliderPanel

          public static JPanel createSliderPanel(BoundedRangeModel model,
                                                 String label)

      Creates a labeled panel containing a slider built using an existing `DefaultBoundedRangeModel`
      Parameters:
        `model` -
        `label` -
      Returns:
        a panel for this model

    - #### createJSlider

          public static JSlider createJSlider(BoundedRangeModel model)

      Creates a JSlider built using a `DefaultBoundedRangeModel` and containing a `MouseWheelListener` and some usual default settings
      Parameters:
        `model` -
      Returns:
        the corresponding `JSlider`

    - #### addMaDKitActionsTo

          public static void addMaDKitActionsTo(Container menuOrToolBar,
                                                AbstractAgent agent)

      Adds to a menu or toolbar the following actions:
      - `KernelAction.EXIT`
      - `KernelAction.COPY`
      - `KernelAction.RESTART`
      - `KernelAction.LAUNCH_NETWORK`
      - `KernelAction.STOP_NETWORK`
      - `GUIManagerAction.CONNECT_TO_IP`
      - `GlobalAction.JCONSOLE`
      - `KernelAction.CONSOLE`
      - `GlobalAction.DEBUG`
      - `GlobalAction.LOAD_LOCAL_DEMOS`
      - `GlobalAction.LOAD_JAR_FILE`
      - `GUIManagerAction.ICONIFY_ALL`
      - `GUIManagerAction.DEICONIFY_ALL`
      - `GUIManagerAction.KILL_AGENTS`
      Parameters:
        `agent` - the agent for which this menu will be built.

    - #### addBooleanActionTo

          public static AbstractButton addBooleanActionTo(Container menuOrToolBar,
                                                          BooleanAction action)

      Creates a `JCheckBoxMenuItem` for a menu or `JToggleButton` for a tool bar
      Parameters:
        `menuOrToolBar` -
        `action` -
      Returns:
        the newly created button: Either a `JToggleButton` or a `JCheckBoxMenuItem`
      Throws:
        `NoSuchMethodException`
        `IllegalAccessException`
        `InvocationTargetException`

    - #### scaleAllAbstractButtonIconsOf

          public static void scaleAllAbstractButtonIconsOf(Container container,
                                                           int size)

      Resizes the icons of all the abstract buttons which are contained in a container.
      Parameters:
        `container` - a container containing abstract buttons
        `size` - the size which should be used for the icons

Fabien Michel, Olivier Gutknecht, Jacques Ferber - February 17 2020