This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing
class DefaultButtonModel

java.lang.Object extended by javax.swing.DefaultButtonModel
All Implemented Interfaces:
Serializable, ButtonModel
Direct Known Subclasses:
JToggleButton.ToggleButtonModel

public class DefaultButtonModel
extends Object
implements ButtonModel, Serializable

The default implementation of a Button component's data model.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.


Field Summary
protected String actionCommand
          The action command string fired by the button.
static int ARMED
          Identifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button.
protected transient ChangeEvent changeEvent
          Only one ChangeEvent is needed per button model instance since the event's only state is the source property.
static int ENABLED
          Identifies the "enabled" bit in the bitmask, which indicates that the button can be selected by an input device (such as a mouse pointer).
protected ButtonGroup group
          The button group that the button belongs to.
protected EventListenerList listenerList
          Stores the listeners on this model.
protected int mnemonic
          The button's mnemonic.
static int PRESSED
          Identifies the "pressed" bit in the bitmask, which indicates that the button is pressed.
static int ROLLOVER
          Identifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button.
static int SELECTED
          Identifies the "selected" bit in the bitmask, which indicates that the button has been selected.
protected int stateMask
          The bitmask used to store the state of the button.
 
Constructor Summary

          Constructs a DefaultButtonModel.
 
Method Summary
 void

          
 void

          
 void

          
protected void

          Notifies all listeners that have registered interest for notification on this event type.
protected void

          Notifies all listeners that have registered interest for notification on this event type.
protected void

          Notifies all listeners that have registered interest for notification on this event type.
 String

          
 ActionListener[]

          Returns an array of all the action listeners registered on this DefaultButtonModel.
 ChangeListener[]

          Returns an array of all the change listeners registered on this DefaultButtonModel.
 ButtonGroup

          Returns the group that the button belongs to.
 ItemListener[]

          Returns an array of all the item listeners registered on this DefaultButtonModel.
 EventListener[]
getListeners(Class listenerType)

          Returns an array of all the objects currently registered as FooListeners upon this model.
 int

          
 Object[]

          Overridden to return null.
 boolean

          
 boolean

          
 boolean

          
 boolean

          
 boolean

          
 void

          
 void

          
 void

          
 void
setActionCommand(String actionCommand)

          
 void
setArmed(boolean b)

          
 void
setEnabled(boolean b)

          
 void

          
 void
setMnemonic(int key)

          
 void
setPressed(boolean b)

          
 void
setRollover(boolean b)

          
 void
setSelected(boolean b)

          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actionCommand

protected String actionCommand
The action command string fired by the button.

ARMED

public static final int ARMED
Identifies the "armed" bit in the bitmask, which indicates partial commitment towards choosing/triggering the button.

changeEvent

protected transient ChangeEvent changeEvent
Only one ChangeEvent is needed per button model instance since the event's only state is the source property. The source of events generated is always "this".

ENABLED

public static final int ENABLED
Identifies the "enabled" bit in the bitmask, which indicates that the button can be selected by an input device (such as a mouse pointer).

group

protected ButtonGroup group
The button group that the button belongs to.

listenerList

protected EventListenerList listenerList
Stores the listeners on this model.

mnemonic

protected int mnemonic
The button's mnemonic.

PRESSED

public static final int PRESSED
Identifies the "pressed" bit in the bitmask, which indicates that the button is pressed.

ROLLOVER

public static final int ROLLOVER
Identifies the "rollover" bit in the bitmask, which indicates that the mouse is over the button.

SELECTED

public static final int SELECTED
Identifies the "selected" bit in the bitmask, which indicates that the button has been selected. Only needed for certain types of buttons - such as radio button or check box.

stateMask

protected int stateMask
The bitmask used to store the state of the button.
Constructor Detail

DefaultButtonModel

public DefaultButtonModel()
Constructs a DefaultButtonModel.

Method Detail

addActionListener

public void addActionListener(ActionListener l)
{@inheritDoc}

Parameters:
l

addChangeListener

public void addChangeListener(ChangeListener l)
{@inheritDoc}

Parameters:
l

addItemListener

public void addItemListener(ItemListener l)
{@inheritDoc}

Parameters:
l

fireActionPerformed

protected void fireActionPerformed(ActionEvent e)
Notifies all listeners that have registered interest for notification on this event type.

Parameters:
e - the ActionEvent to deliver to listeners

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent e)
Notifies all listeners that have registered interest for notification on this event type.

Parameters:
e - the ItemEvent to deliver to listeners

fireStateChanged

protected void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.


getActionCommand

public String getActionCommand()
{@inheritDoc}


getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the action listeners registered on this DefaultButtonModel.

Returns:
all of this model's ActionListeners or an empty array if no action listeners are currently registered

getChangeListeners

public ChangeListener[] getChangeListeners()
Returns an array of all the change listeners registered on this DefaultButtonModel.

Returns:
all of this model's ChangeListeners or an empty array if no change listeners are currently registered

getGroup

public ButtonGroup getGroup()
Returns the group that the button belongs to. Normally used with radio buttons, which are mutually exclusive within their group.

Returns:
the ButtonGroup that the button belongs to

getItemListeners

public ItemListener[] getItemListeners()
Returns an array of all the item listeners registered on this DefaultButtonModel.

Returns:
all of this model's ItemListeners or an empty array if no item listeners are currently registered

getListeners

public EventListener[] getListeners(Class listenerType)
Returns an array of all the objects currently registered as FooListeners upon this model. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a DefaultButtonModel instance m for its action listeners with the following code:

ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));
If no such listeners exist, this method returns an empty array.

Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this model, or an empty array if no such listeners have been added

getMnemonic

public int getMnemonic()
{@inheritDoc}


getSelectedObjects

public Object[] getSelectedObjects()
Overridden to return null.


isArmed

public boolean isArmed()
{@inheritDoc}


isEnabled

public boolean isEnabled()
{@inheritDoc}


isPressed

public boolean isPressed()
{@inheritDoc}


isRollover

public boolean isRollover()
{@inheritDoc}


isSelected

public boolean isSelected()
{@inheritDoc}


removeActionListener

public void removeActionListener(ActionListener l)
{@inheritDoc}

Parameters:
l

removeChangeListener

public void removeChangeListener(ChangeListener l)
{@inheritDoc}

Parameters:
l

removeItemListener

public void removeItemListener(ItemListener l)
{@inheritDoc}

Parameters:
l

setActionCommand

public void setActionCommand(String actionCommand)
{@inheritDoc}

Parameters:
actionCommand

setArmed

public void setArmed(boolean b)
{@inheritDoc}

Parameters:
b

setEnabled

public void setEnabled(boolean b)
{@inheritDoc}

Parameters:
b

setGroup

public void setGroup(ButtonGroup group)
{@inheritDoc}

Parameters:
group

setMnemonic

public void setMnemonic(int key)
{@inheritDoc}

Parameters:
key

setPressed

public void setPressed(boolean b)
{@inheritDoc}

Parameters:
b

setRollover

public void setRollover(boolean b)
{@inheritDoc}

Parameters:
b

setSelected

public void setSelected(boolean b)
{@inheritDoc}

Parameters:
b


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.