Class ControlStack

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class ControlStack extends CheckBoxList<Control>
List component that contains Control objects. It is a CheckBoxList so they can be dragged up and down and selected on and off.
Since:
13 Mar 2013
Author:
Mark Taylor
See Also:
  • Constructor Details

    • ControlStack

      public ControlStack()
      Constructs a stack with a default (empty) model.
    • ControlStack

      public ControlStack(ControlStackModel stackModel)
      Constructs a stack with a given model.
      Parameters:
      stackModel - stack model
  • Method Details

    • getStackModel

      public ControlStackModel getStackModel()
      Returns the list model used for this control stack.
      Returns:
      stack model
    • configureEntryRenderer

      protected void configureEntryRenderer(JComponent renderer, Control control, int index)
      Description copied from class: CheckBoxList
      This method is called whenever the list cell needs to be painted.
      Specified by:
      configureEntryRenderer in class CheckBoxList<Control>
      Parameters:
      renderer - renderer object supplied at construction time
      control - list entry
      index - index in list at which entry appears
    • isChecked

      public boolean isChecked(Control control)
      Description copied from class: CheckBoxList
      Indicates whether the checkbox for a given item is selected.
      Specified by:
      isChecked in class CheckBoxList<Control>
      Parameters:
      control - list entry
      Returns:
      true iff item is selected
    • setChecked

      public void setChecked(Control control, boolean active)
      Description copied from class: CheckBoxList
      Sets whether the checkbox for a given item is selected. Called when the user interacts with the checkbox. It is up to the concrete implementation to ensure that this is reflected by the isChecked method.
      Specified by:
      setChecked in class CheckBoxList<Control>
      Parameters:
      control - list entry
      active - whether item should be selected
    • moveItem

      public void moveItem(int ifrom, int ito)
      Description copied from class: CheckBoxList
      Indicates that the user has requested a reordering of the list model. It is up to the concrete implementation to ensure that this is reflected in the list model.
      Specified by:
      moveItem in class CheckBoxList<Control>
      Parameters:
      ifrom - source list index
      ito - destination list index
    • getCurrentControl

      public Control getCurrentControl()
      Returns the currently selected control.
      Returns:
      current control, or null
    • addControl

      public void addControl(Control control)
      Adds a control to this stack.
      Parameters:
      control - new control
    • removeControl

      public void removeControl(Control control)
      Removes a given control from this stack.
      Parameters:
      control - control to remove
    • createRemoveAction

      public Action createRemoveAction(String name, String description)
      Returns an action which deletes the currently selected control from the stack.
      Parameters:
      name - action name
      description - action short description (tooltip)
      Returns:
      new action