com.sas.visuals
Class DefaultButtonModel

com.sas.visuals.DefaultButtonModel
All Implemented Interfaces:
ActionSource, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, com.sas.ViewInterface, ButtonModelInterface, MultipleValueEventSourceInterface, java.awt.ItemSelectable, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
AlarmButtonModel, TabButtonModel, ToggleButtonModel

public class DefaultButtonModel
implements ButtonModelInterface

DefaultButtonModel is an implementation of the ButtonModelInterface interface that holds the state information for a specific button and sends out the Action and Item events that the button forwards to its listeners.

See Also:
DefaultButtonListener, BaseButton, ButtonListenerInterface, Serialized Form

Field Summary
protected  java.lang.String actionCommand
           
protected  java.awt.event.ActionListener actionListenerList
           
protected  boolean armed
           
protected  boolean disabled
           
protected  java.awt.event.ItemListener itemListenerList
           
protected  char keyAccelerator
           
protected  int nextState
           
protected  boolean pressed
           
protected  int prevState
           
protected  boolean rollover
           
protected  boolean selected
           
protected  SelectionGroupInterface selectionGroup
           
protected  int state
           
protected  int stateCount
           
 
Constructor Summary
DefaultButtonModel()
          Default Constructor
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds the specified action listener to receive action events from this buttonModel.
 void addItemListener(java.awt.event.ItemListener listener)
          Adds the specified item listener to receive item events from this buttonModel.
 java.lang.String getActionCommand()
          Get the ActionCommand used when an ActionEvent is sent
 char getKeyAccelerator()
          Get the key that is used to trigger the button.
 int getNextState()
          Get the next state of the ButtonModel if it has multiple states.
 int getPrevState()
          Get the prev state of the ButtonModel if it has multiple states.
 java.lang.Object[] getSelectedObjects()
          Get the selected objects.
 SelectionGroupInterface getSelectionGroup()
          Get the SelectionGroupInterface object used to provide a single selection behavior of a group of buttons.
 int getState()
          Get the state of the buttonModel.
 int getStateCount()
          Get the number of possible states for the buttonModel.
 boolean isArmed()
          Return if the button is armed.
 boolean isDisabled()
          Return if the button is disabled.
 boolean isPressed()
          Return if the button is pressed.
 boolean isRollover()
          Return if the button is rollover.
 boolean isSelected()
          Return if the button is selected.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes the specified action listener so that it no longer receives action events from this buttonModel.
 void removeItemListener(java.awt.event.ItemListener l)
          Removes the specified item listener so that it no longer receives item events from this buttonModel.
 void setActionCommand(java.lang.String cmd)
          Set the ActionCommand used when an ActionEvent is sent
 void setArmed(boolean a)
          Set the button armed state.
 void setDefaultValues()
          Set the default internal values for the AnimationIconView.
 void setDisabled(boolean d)
          Set the button disabled state.
 void setKeyAccelerator(char key)
          Set the key that is used to trigger the button.
 void setPressed(boolean p)
          Set the button pressed state.
 void setRollover(boolean r)
          Set the button rollover state.
 void setSelected(boolean s)
          Set the button selected state.
 void setSelectionGroup(SelectionGroupInterface group)
          Set the selectionGroup used to provide singleSelection behavior to a group of buttons.
 void setState(int s)
          Set the state of the button.
 

Field Detail

actionCommand

protected java.lang.String actionCommand

keyAccelerator

protected char keyAccelerator

nextState

protected int nextState

prevState

protected int prevState

selectionGroup

protected SelectionGroupInterface selectionGroup

state

protected int state

stateCount

protected int stateCount

armed

protected boolean armed

disabled

protected boolean disabled

rollover

protected boolean rollover

pressed

protected boolean pressed

selected

protected boolean selected

actionListenerList

protected transient java.awt.event.ActionListener actionListenerList

itemListenerList

protected transient java.awt.event.ItemListener itemListenerList
Constructor Detail

DefaultButtonModel

public DefaultButtonModel()
Default Constructor

Method Detail

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds the specified action listener to receive action events from this buttonModel. Action events occur when a user presses and releases the mouse over the button using this buttonModel.

Specified by:
addActionListener in interface ActionSource
Parameters:
listener - an object which handles ActionEvent events the listener is not added a second time if it already exists in the list of listeners for this event.
See Also:
ActionListener, removeActionListener(java.awt.event.ActionListener)

addItemListener

public void addItemListener(java.awt.event.ItemListener listener)
Adds the specified item listener to receive item events from this buttonModel. Item events occur when the selected state is changed.

Specified by:
addItemListener in interface java.awt.ItemSelectable
See Also:
ItemListener, removeItemListener(java.awt.event.ItemListener)

getActionCommand

public java.lang.String getActionCommand()
Get the ActionCommand used when an ActionEvent is sent

Specified by:
getActionCommand in interface ButtonModelInterface
See Also:
setActionCommand(java.lang.String), ActionEvent

getKeyAccelerator

public char getKeyAccelerator()
Get the key that is used to trigger the button.

Specified by:
getKeyAccelerator in interface ButtonModelInterface
See Also:
setKeyAccelerator(char)

getNextState

public int getNextState()
Get the next state of the ButtonModel if it has multiple states. This button model only has 2.

Specified by:
getNextState in interface ButtonModelInterface

getPrevState

public int getPrevState()
Get the prev state of the ButtonModel if it has multiple states. This button model only has 2.

Specified by:
getPrevState in interface ButtonModelInterface

getSelectionGroup

public SelectionGroupInterface getSelectionGroup()
Get the SelectionGroupInterface object used to provide a single selection behavior of a group of buttons.

Specified by:
getSelectionGroup in interface ButtonModelInterface
See Also:
setSelectionGroup(com.sas.visuals.SelectionGroupInterface)

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Get the selected objects. DOES NOTHING, here to satisfy ItemSelectable interface.

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
null
See Also:
ItemSelectable

getState

public int getState()
Get the state of the buttonModel.

Specified by:
getState in interface ButtonModelInterface
See Also:
setState(int)

getStateCount

public int getStateCount()
Get the number of possible states for the buttonModel.

Specified by:
getStateCount in interface ButtonModelInterface

isArmed

public boolean isArmed()
Return if the button is armed.

Specified by:
isArmed in interface ButtonModelInterface
Returns:
true if armed, false otherwise.
See Also:
setArmed(boolean)

isDisabled

public boolean isDisabled()
Return if the button is disabled.

Specified by:
isDisabled in interface ButtonModelInterface
Returns:
true if disabled, false otherwise.
See Also:
setDisabled(boolean)

isRollover

public boolean isRollover()
Return if the button is rollover.

Specified by:
isRollover in interface ButtonModelInterface
Returns:
true if rollover, false otherwise.
See Also:
setRollover(boolean)

isPressed

public boolean isPressed()
Return if the button is pressed.

Specified by:
isPressed in interface ButtonModelInterface
Returns:
true if pressed, false otherwise.
See Also:
setPressed(boolean)

isSelected

public boolean isSelected()
Return if the button is selected.

Specified by:
isSelected in interface ButtonModelInterface
Returns:
true if selected, false otherwise.
See Also:
setSelected(boolean)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes the specified action listener so that it no longer receives action events from this buttonModel. Action events occur when a user presses and releases the mouse over this button.

Specified by:
removeActionListener in interface ActionSource
Parameters:
l - an object which handles ActionEvent events
See Also:
ActionListener, addActionListener(java.awt.event.ActionListener)

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Removes the specified item listener so that it no longer receives item events from this buttonModel. Item events occur when the selected state is changed.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
See Also:
ItemListener, addItemListener(java.awt.event.ItemListener)

setActionCommand

public void setActionCommand(java.lang.String cmd)
Set the ActionCommand used when an ActionEvent is sent

Specified by:
setActionCommand in interface ButtonModelInterface
See Also:
getActionCommand(), ActionEvent

setArmed

public void setArmed(boolean a)
Set the button armed state. The armed state is used when the button has been pressed and the mouse is moved off or on the button component.

Specified by:
setArmed in interface ButtonModelInterface
Parameters:
armed - true if armed, false otherwise.
See Also:
isArmed()

setDefaultValues

public void setDefaultValues()
Set the default internal values for the AnimationIconView.

Specified by:
setDefaultValues in interface com.sas.ComponentInterface
Overrides:
setDefaultValues in class com.sas.Component
See Also:
ComponentInterface.setDefaultValues()

setDisabled

public void setDisabled(boolean d)
Set the button disabled state.

Specified by:
setDisabled in interface ButtonModelInterface
Parameters:
disabled - true if disabled, false otherwise.
See Also:
isDisabled()

setKeyAccelerator

public void setKeyAccelerator(char key)
Set the key that is used to trigger the button.

Specified by:
setKeyAccelerator in interface ButtonModelInterface
See Also:
getKeyAccelerator()

setPressed

public void setPressed(boolean p)
Set the button pressed state. This sends an actionEvent to any actionListeners if set to false after being true and armed is true.

Specified by:
setPressed in interface ButtonModelInterface
Parameters:
pressed - true if pressed, false otherwise.
See Also:
isPressed()

setRollover

public void setRollover(boolean r)
Set the button rollover state. The rollover state is used when the mouse is just moved over the button component without being pressed.

Specified by:
setRollover in interface ButtonModelInterface
Parameters:
rollover - true if rollover, false otherwise.
See Also:
isRollover()

setSelected

public void setSelected(boolean s)
Set the button selected state. The selected state is used when the button component is in a selectionGroup an selected or another button is selected an the original button is deselected. This sends an ItemEvent to any itemListeners when it is set the the opposite of what isSelected() returns.

Specified by:
setSelected in interface ButtonModelInterface
Parameters:
selected - true if selected, false otherwise.
See Also:
isSelected(), ItemSelectable

setSelectionGroup

public void setSelectionGroup(SelectionGroupInterface group)
Set the selectionGroup used to provide singleSelection behavior to a group of buttons.

Specified by:
setSelectionGroup in interface ButtonModelInterface
Parameters:
selectionGroup - selectionGroup to add button to.
See Also:
getSelectionGroup()

setState

public void setState(int s)
Set the state of the button.

Specified by:
setState in interface ButtonModelInterface
Parameters:
state - the button state
See Also:
getState()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.