madkit.gui

## Class SwingUtil

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

-     public final class SwingUtil
      extends java.lang.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 javax.swing.ImageIcon` | `MADKIT_LOGO` The MaDKit's logo
    `static javax.swing.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 javax.swing.AbstractButton` | `addBooleanActionTo(java.awt.Container menuOrToolBar, BooleanAction action)` Creates a `JCheckBoxMenuItem` for a menu or `JToggleButton` for a tool bar
    `static void` | `addMaDKitActionsTo(java.awt.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 javax.swing.JSlider` | `createJSlider(javax.swing.BoundedRangeModel model)` Creates a JSlider built using a `DefaultBoundedRangeModel` and containing a `MouseWheelListener` and some usual default settings
    `static javax.swing.JPanel` | `createSliderPanel(javax.swing.BoundedRangeModel model, java.lang.String label)` Creates a labeled panel containing a slider built using an existing `DefaultBoundedRangeModel`
    `static javax.swing.JPanel` | `createSliderPanel(javax.swing.JSlider slider, java.lang.String label)` Creates a labeled panel containing a slider with default size.
    `static javax.swing.JPanel` | `createSliderPanel(javax.swing.JSlider slider, java.lang.String label, int width)` Creates a labeled panel containing a slider and considering a particular width
    `static void` | `scaleAllAbstractButtonIconsOf(java.awt.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 javax.swing.ImageIcon MADKIT_LOGO

      The MaDKit's logo

    - #### MADKIT_LOGO_SMALL

          public static final javax.swing.ImageIcon MADKIT_LOGO_SMALL

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

  - ### Method Detail

    - #### createSliderPanel

          public static javax.swing.JPanel createSliderPanel(javax.swing.JSlider slider,
                                                             java.lang.String label)

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

    - #### createSliderPanel

          public static javax.swing.JPanel createSliderPanel(javax.swing.JSlider slider,
                                                             java.lang.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 javax.swing.JPanel createSliderPanel(javax.swing.BoundedRangeModel model,
                                                             java.lang.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 javax.swing.JSlider createJSlider(javax.swing.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(java.awt.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 javax.swing.AbstractButton addBooleanActionTo(java.awt.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:
        `java.lang.NoSuchMethodException`
        `java.lang.IllegalAccessException`
        `java.lang.reflect.InvocationTargetException`

    - #### scaleAllAbstractButtonIconsOf

          public static void scaleAllAbstractButtonIconsOf(java.awt.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 - September 9 2019