org.bs.mdi.swing
Class SwingCommandButton

java.lang.Object
  extended byorg.bs.mdi.swing.SwingCommandTrigger
      extended byorg.bs.mdi.swing.SwingCommandButton
All Implemented Interfaces:
ActionListener, CommandTrigger, EventListener

public class SwingCommandButton
extends SwingCommandTrigger
implements ActionListener

A Wrapper for AbstractButtons which adds CommandTrigger functionality.


Field Summary
protected static int TYPE_BUTTON
           
protected static int TYPE_CHECKBOX
           
protected static int TYPE_CUSTOM
           
protected static int TYPE_MENUITEM
           
protected static int TYPE_RADIOBUTTON
           
protected static int TYPE_TOOLBUTTON
           
protected static int TYPE_TOOLTOGGLEBUTTON
           
 
Constructor Summary
  SwingCommandButton(SwingCommand command, AbstractButton button)
          Creates a new custom SwingCommandButton based on an AbstractButton.
protected SwingCommandButton(SwingCommand command, AbstractButton button, int type)
          This constructor is for framework internal use only.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void commandExecuted(CommandTrigger trigger)
          Informs this trigger that the associated command has been executed.
 void commandUpdated()
          Informs this trigger that the associated command has changed.
static AbstractButton createButton(SwingCommand command)
          Creates a new standard button and associates it with the given command.
static AbstractButton createCheckBox(SwingCommand command)
          Creates a new checkbox and associates it with the given command.
static AbstractButton createMenuItem(SwingCommand command)
          Creates a new menu item and associates it with the given command.
static AbstractButton createRadioButton(SwingCommand command)
          Creates a new radio button and associates it with the given command.
static AbstractButton createToolButton(SwingCommand command)
          Creates a new toolbar button and associates it with the given command.
static AbstractButton createToolToggleButton(SwingCommand command)
          Creates a new toolbar togglebutton and associates it with the given command.
 AbstractButton getButton()
          Gets the button "wrapped" behind this object.
 boolean removeFrom(Container container)
          Removes this trigger from the sepecified container.
 void setEnabled(boolean enabled)
          Enables or disables this command trigger.
 
Methods inherited from class org.bs.mdi.swing.SwingCommandTrigger
execute, getCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_CUSTOM

protected static final int TYPE_CUSTOM
See Also:
Constant Field Values

TYPE_TOOLBUTTON

protected static final int TYPE_TOOLBUTTON
See Also:
Constant Field Values

TYPE_TOOLTOGGLEBUTTON

protected static final int TYPE_TOOLTOGGLEBUTTON
See Also:
Constant Field Values

TYPE_BUTTON

protected static final int TYPE_BUTTON
See Also:
Constant Field Values

TYPE_MENUITEM

protected static final int TYPE_MENUITEM
See Also:
Constant Field Values

TYPE_CHECKBOX

protected static final int TYPE_CHECKBOX
See Also:
Constant Field Values

TYPE_RADIOBUTTON

protected static final int TYPE_RADIOBUTTON
See Also:
Constant Field Values
Constructor Detail

SwingCommandButton

public SwingCommandButton(SwingCommand command,
                          AbstractButton button)
Creates a new custom SwingCommandButton based on an AbstractButton. Use this constructor use this Wrapper with custom components.

Parameters:
command - the command to be associated with the SwingCommandButton
button - the component to be wrapped

SwingCommandButton

protected SwingCommandButton(SwingCommand command,
                             AbstractButton button,
                             int type)
This constructor is for framework internal use only.

Parameters:
command -
button -
type -
Method Detail

createToolButton

public static AbstractButton createToolButton(SwingCommand command)
Creates a new toolbar button and associates it with the given command.

Parameters:
command - the command to be associated with the button
Returns:
a button linked with the given command

createToolToggleButton

public static AbstractButton createToolToggleButton(SwingCommand command)
Creates a new toolbar togglebutton and associates it with the given command.

Parameters:
command - the command to be associated with the button
Returns:
a togglebutton linked with the given command

createButton

public static AbstractButton createButton(SwingCommand command)
Creates a new standard button and associates it with the given command.

Parameters:
command - the command to be associated with the button
Returns:
a button linked with the given command

createMenuItem

public static AbstractButton createMenuItem(SwingCommand command)
Creates a new menu item and associates it with the given command.

Parameters:
command - the command to be associated with the menu item
Returns:
a menu item linked with the given command

createCheckBox

public static AbstractButton createCheckBox(SwingCommand command)
Creates a new checkbox and associates it with the given command.

Parameters:
command - the command to be associated with the checkbox
Returns:
a checkbox linked with the given command

createRadioButton

public static AbstractButton createRadioButton(SwingCommand command)
Creates a new radio button and associates it with the given command.

Parameters:
command - the command to be associated with the radio button
Returns:
a radio button linked with the given command

getButton

public AbstractButton getButton()
Gets the button "wrapped" behind this object.

Returns:
the wrapped button

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: CommandTrigger
Enables or disables this command trigger.

Specified by:
setEnabled in interface CommandTrigger
Specified by:
setEnabled in class SwingCommandTrigger

actionPerformed

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

commandExecuted

public void commandExecuted(CommandTrigger trigger)
Description copied from interface: CommandTrigger
Informs this trigger that the associated command has been executed. Note that the command may have been fired by either this trigger or another trigger which has been associated with the command.

Specified by:
commandExecuted in interface CommandTrigger
Overrides:
commandExecuted in class SwingCommandTrigger

commandUpdated

public void commandUpdated()
Description copied from interface: CommandTrigger
Informs this trigger that the associated command has changed. This typically includes name or description changes. The trigger should update itself to reflect that changes.

Specified by:
commandUpdated in interface CommandTrigger
Overrides:
commandUpdated in class SwingCommandTrigger

removeFrom

public boolean removeFrom(Container container)
Description copied from class: SwingCommandTrigger
Removes this trigger from the sepecified container.

Specified by:
removeFrom in class SwingCommandTrigger
Parameters:
container - the container which is supposed to contain this trigger
Returns:
true if the trigger has been removed, false otherwise