Save This Page
Home » openjdk-7 » javax » swing » [javadoc | source]
javax.swing
public class: DefaultButtonModel [javadoc | source]
java.lang.Object
   javax.swing.DefaultButtonModel

All Implemented Interfaces:
    ButtonModel, Serializable

Direct Known Subclasses:
    ToggleButtonModel, ToggleButtonModel

The default implementation of ButtonModel . The purpose of this class is to model the dynamic state of an abstract button. The concrete button type holding this state may be a a "toggle" button (checkbox, radio button) or a "push" button (menu button, button). If the model is disabled, only the "selected" property can be changed. An attempt to change the "armed", "rollover" or "pressed" properties while the model is disabled will be blocked. Any successful (non-blocked) change to the model's properties will trigger the firing of a ChangeEvent. Any change to the "selected" property will trigger the firing of an ItemEvent in addition to ChangeEvent. This is true whether the model is enabled or not. One other state change is special: the transition from "enabled, armed and pressd" to "enabled, armed and not-pressed". This is considered the "trailing edge" of a successful mouse click, and therefore fires an ActionEvent in addition to a ChangeEvent. In all other respects this class is just a container of boolean flags.
Field Summary
public static final  int ARMED    Indicates that the button is partially committed to being pressed, but not entirely. This usually happens when a user has pressed but not yet released the mouse button. 
public static final  int ENABLED    State constant indicating that the button is enabled. Buttons cannot be pressed or selected unless they are enabled. 
public static final  int PRESSED    State constant indicating that the user is holding down the button. When this transitions from true to false, an ActionEvent may be fired, depending on the value of the "armed" property. 
public static final  int ROLLOVER    State constant indicating that the mouse is currently positioned over the button. 
public static final  int SELECTED    State constant indicating that the button is selected. This constant is only meaningful for toggle-type buttons (radio buttons, checkboxes). 
protected  int stateMask    Represents the "state properties" (armed, enabled, pressed, rollover and selected) by a bitwise combination of integer constants. 
protected  EventListenerList listenerList    List of ItemListeners, ChangeListeners, and ActionListeners registered on this model. 
protected  ChangeEvent changeEvent    The single ChangeEvent this model (re)uses to call its ChangeListeners. 
protected  ButtonGroup group    The group this model belongs to. Only one button in a group may be selected at any given time. 
protected  int mnemonic    The key code (one of java.awt.event.KeyEvent VK_) used to press this button via a keyboard interface. 
protected  String actionCommand    The string used as the "command" property of any ActionEvent this model sends. 
Constructor:
 public DefaultButtonModel() 
Method from javax.swing.DefaultButtonModel Summary:
addActionListener,   addChangeListener,   addItemListener,   fireActionPerformed,   fireItemStateChanged,   fireStateChanged,   getActionCommand,   getActionListeners,   getChangeListeners,   getGroup,   getItemListeners,   getListeners,   getMnemonic,   getSelectedObjects,   isArmed,   isEnabled,   isPressed,   isRollover,   isSelected,   removeActionListener,   removeChangeListener,   removeItemListener,   setActionCommand,   setArmed,   setEnabled,   setGroup,   setMnemonic,   setPressed,   setRollover,   setSelected
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.DefaultButtonModel Detail:
 public  void addActionListener(ActionListener l) 
    Add an ActionListener to the model. Usually only called to subscribe an AbstractButton's listener to the model.
 public  void addChangeListener(ChangeListener l) 
    Add a ChangeListener to the model. Usually only called to subscribe an AbstractButton's listener to the model.
 public  void addItemListener(ItemListener l) 
    Add an ItemListener to the model. Usually only called to subscribe an AbstractButton's listener to the model.
 protected  void fireActionPerformed(ActionEvent e) 
    Inform each ActionListener in the #listenerList that an ActionEvent has occurred. This happens in response to the any change to the #stateMask field which makes the enabled, armed and pressed properties all simultaneously true.
 protected  void fireItemStateChanged(ItemEvent e) 
    Inform each ItemListener in the #listenerList that an ItemEvent has occurred. This happens in response to any change to the #stateMask field.
 protected  void fireStateChanged() 
    Inform each ChangeListener in the #listenerList that a ChangeEvent has occurred. This happens in response to the any change to a property of the model.
 public String getActionCommand() 
    Returns the current value of the model's "actionCommand" property.
 public ActionListener[] getActionListeners() 
    Returns all registered ActionListener objects.
 public ChangeListener[] getChangeListeners() 
    Returns all registered ChangeListener objects.
 public ButtonGroup getGroup() 
    Returns the current value of the model's "group" property.
 public ItemListener[] getItemListeners() 
    Returns all registered ItemListener objects.
 public EventListener[] getListeners(Class listenerType) 
    Returns a specified class of listeners.
 public int getMnemonic() 
    Get the value of the model's "mnemonic" property.
 public Object[] getSelectedObjects() 
 public boolean isArmed() 
    Get the value of the model's "armed" property.
 public boolean isEnabled() 
    Get the value of the model's "enabled" property.
 public boolean isPressed() 
    Get the value of the model's "pressed" property.
 public boolean isRollover() 
    Get the value of the model's "rollover" property.
 public boolean isSelected() 
    Get the value of the model's "selected" property.
 public  void removeActionListener(ActionListener l) 
    Remove an ActionListener to the model. Usually only called to unsubscribe an AbstractButton's listener to the model.
 public  void removeChangeListener(ChangeListener l) 
    Remove a ChangeListener to the model. Usually only called to unsubscribe an AbstractButton's listener to the model.
 public  void removeItemListener(ItemListener l) 
    Remove an ItemListener to the model. Usually only called to unsubscribe an AbstractButton's listener to the model.
 public  void setActionCommand(String s) 
    Set the value of the model's "actionCommand" property. This property is used as the "command" property of the ActionEvent fired from the model.
 public  void setArmed(boolean a) 
    Set the value of the model's "armed" property.
 public  void setEnabled(boolean e) 
    Set the value of the model's "enabled" property.
 public  void setGroup(ButtonGroup g) 
    Set the value of the model's "group" property. The model is said to be a member of the ButtonGroup held in its "group" property, and only one model in a given group can have their "selected" property be true at a time.
 public  void setMnemonic(int key) 
    Set the value of the model's "mnemonic" property.
 public  void setPressed(boolean p) 
    Set the value of the model's "pressed" property.
 public  void setRollover(boolean r) 
    Set the value of the model's "rollover" property.
 public  void setSelected(boolean s) 
    Set the value of the model's "selected" property.