Class CommonToolBar

All Implemented Interfaces:
ActionListener, ItemListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, SwingConstants

public class CommonToolBar extends JToolBar implements ActionListener, ItemListener
See Also:
  • Field Details

  • Constructor Details

    • CommonToolBar

      public CommonToolBar(int orientation)
      Creates a new tool bar with a specified name and orientation. All other constructors call this constructor.
      Parameters:
      orientation - the initial orientation -- it must be either HORIZONTAL or VERTICAL
  • Method Details

    • setSelectedToggle

      public void setSelectedToggle(String s)
      Set which toggle buttonis selected
    • getMainButtonGroup

      public ButtonGroup getMainButtonGroup()
      Get the primary button group so that we can add other buttons to the group
      Returns:
      the primary button group so that we can add other buttons to the group
    • add

      public void add(ToolBarButton button)
      Add a regular button to the toolbar
      Parameters:
      button - the ToolBarButton to add.
    • add

      public void add(JToggleButton toggleButton)
      Add a toggle button to the toolbar.
      Parameters:
      toggleButton - the button to add.
    • add

      public void add(JToggleButton toggleButton, boolean toGroup)
      Add a toggle button to the toolbar.
      Parameters:
      toggleButton - the button to add.
      toGroup - if true and to the primary button group
    • remove

      public void remove(JToggleButton toggleButton)
      remove a toggle button from the toolbar.
      Parameters:
      toggleButton - the button to remove.
    • getDefaultToggleButton

      public JToggleButton getDefaultToggleButton()
      Get the default toggle button. This will become active if you click an active toggle button to turn it off.
      Returns:
      the default toggle buton.
    • setDefaultToggleButton

      public void setDefaultToggleButton(ToolBarToggleButton defaultToggleButton)
      Set the default toggle button. This will become active if you click an active toggle button to turn it off.
      Parameters:
      defaultToggleButton - the default toggle button.
    • resetDefaultSelection

      public void resetDefaultSelection()
      Reset the default toggle button selection
    • getActiveCommand

      public String getActiveCommand()
      Get the command of the active toggle button
      Returns:
      the command of the active toggle button
    • getActiveButton

      public ToolBarToggleButton getActiveButton()
      Get which tool bar toggle button from the primary button group is active
      Returns:
      the active toolbar toggle button (from the primary button group), or null.
    • isDefaultActivated

      public boolean isDefaultActivated()
      Check whether the default button is active
      Returns:
      true if the default button is active.
    • isButtonActivated

      public boolean isButtonActivated(AbstractButton tbtb)
      Check whether a given button is active
      Parameters:
      tbtb - the button to test
      Returns:
      true if the default button is active.
    • addToolBarListener

      public void addToolBarListener(IToolBarListener listener)
      Add a toolBar listener
      Parameters:
      ToolBarListener - the listener to add
    • removeToolBarListener

      public void removeToolBarListener(IToolBarListener listener)
      Remove a ToolBarListener.
      Parameters:
      ToolBarListener - the ToolBarListener to remove.
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Specified by:
      actionPerformed in interface ActionListener
    • itemStateChanged

      public void itemStateChanged(ItemEvent e)
      Specified by:
      itemStateChanged in interface ItemListener
    • getButton

      public AbstractButton getButton(String actionCommand)
      Find a button from the action command
      Parameters:
      actionCommand - the action command to match
      Returns:
      the button or null if not found
    • setButtonEnabled

      public void setButtonEnabled(String actionCommand, boolean enabled)
      Set a button enabled by the action command
      Parameters:
      actionCommand - the action command
      enabled - the flag