Class FWBoxPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FWBoxPanel extends JPanel
Use this class to easily build groups of widgets like buttons, checkboxes or popup buttons in a row or column (box layout), with struts and glue in between. Added buttons are remembered by action or action command.
Author:
Andreas Enders
See Also:
  • Field Details

  • Constructor Details

    • FWBoxPanel

      public FWBoxPanel()
      Constructor for FWBoxPanel - X-Axis is used by default.
    • FWBoxPanel

      public FWBoxPanel(int aAxis)
      Constructor for FWBoxPanel with the given axis.
      Parameters:
      aAxis - X_AXIS or Y_AXIS
  • Method Details

    • addButton

      public FWButton addButton(Action aAction)
      Adds a button for an action.
      Parameters:
      aAction - the action
      Returns:
      the button
    • addButton

      public void addButton(JButton aButton)
      Adds a button (remembered by its action command, if any).
      Parameters:
      aButton - the button
    • addButton

      public FWButton addButton(String aCaption, ActionListener aActionListener, String aActionCommand)
      Adds an enabled button; the first letter of the caption is the mnemonic.
      Parameters:
      aCaption - caption of the button
      aActionListener - listener of the button
      aActionCommand - action command
      Returns:
      the button
    • addButton

      public FWButton addButton(String aCaption, ActionListener aActionListener, String aActionCommand, boolean aEnabled)
      Adds a button; the first letter of the caption is the mnemonic.
      Parameters:
      aCaption - caption of the button
      aActionListener - listener of the button
      aActionCommand - action command
      aEnabled - true if the button is enabled
      Returns:
      the button
    • addButton

      public FWButton addButton(String aCaption, char aMnemonic, ActionListener aActionListener, String aActionCommand, boolean aEnabled)
      Adds a button.
      Parameters:
      aCaption - caption of the button
      aMnemonic - mnemonic
      aActionListener - listener of the button
      aActionCommand - action command
      aEnabled - true if the button is enabled
      Returns:
      the button
    • addButton

      public FWButton addButton(String aCaption, char aMnemonic, ActionListener aActionListener, String aActionCommand, boolean aEnabled, Icon aIcon)
      Adds a button with icon.
      Parameters:
      aCaption - caption of the button
      aMnemonic - mnemonic
      aActionListener - listener of the button
      aActionCommand - action command
      aEnabled - true if the button is enabled
      aIcon - icon, or null
      Returns:
      the button
    • addDefaultButton

      public FWButton addDefaultButton(String aButtonType, String aActionCommand, ActionListener aActionListener)
      Adds an enabled default button (localised caption and icon of the type).
      Parameters:
      aButtonType - button type, one of the FWButton.BUTTON_* constants
      aActionCommand - action command
      aActionListener - listener of the button
      Returns:
      the added Button for keeping the reference
    • addDefaultButton

      public FWButton addDefaultButton(String aButtonType, String aActionCommand, ActionListener aActionListener, boolean aEnabled)
      Adds a default button (localised caption and icon of the type).
      Parameters:
      aButtonType - button type, one of the FWButton.BUTTON_* constants
      aActionCommand - action command
      aActionListener - listener of the button
      aEnabled - true if the button is enabled
      Returns:
      the added Button for keeping the reference
    • addCheckbox

      public JCheckBox addCheckbox(String aCaption, String aActionCommand, ActionListener aActionListener, boolean aSelected)
      Adds a checkbox with action listener (remembered by action command).
      Parameters:
      aCaption - caption of the checkbox
      aActionCommand - action command
      aActionListener - listener of the checkbox
      aSelected - initial state
      Returns:
      the new JCheckBox
    • addCheckbox

      public JCheckBox addCheckbox(String aCaption, ItemListener aItemListener, boolean aSelected)
      Adds a checkbox with item listener (not remembered).
      Parameters:
      aCaption - caption of the checkbox
      aItemListener - listener of the checkbox
      aSelected - initial state
      Returns:
      the new JCheckBox
    • addStrut

      public void addStrut()
      Adding Strut of 6 px
    • addStrut

      public Component addStrut(int aWidth)
      Adds a fixed space along the axis.
      Parameters:
      aWidth - size of the space in pixels
      Returns:
      the strut component
    • addDynamicStrut

      public Component addDynamicStrut(int aMinWidth, int aPrefWidth)
      Adds a space along the axis that may shrink to a minimum size.
      Parameters:
      aMinWidth - minimum size in pixels
      aPrefWidth - preferred (and maximum) size in pixels
      Returns:
      the strut component
    • addGlue

      public void addGlue()
      adds a Glue
    • getButton

      public AbstractButton getButton(Action aAction)
      Parameters:
      aAction - the action
      Returns:
      the button added for the action, or null
    • getButton

      public AbstractButton getButton(String aActionCommand)
      Parameters:
      aActionCommand - the action command
      Returns:
      the button with the action command, or null
    • setEnabled

      public void setEnabled(Action aAction, boolean aEnabled)
      Enables or disables the button of an action.
      Parameters:
      aAction - the action
      aEnabled - true to enable
    • setEnabled

      public void setEnabled(String aActionCommand, boolean aEnabled)
      Enables or disables the button with an action command.
      Parameters:
      aActionCommand - the action command
      aEnabled - true to enable