/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The default implementation of a <code>Button</code> component's data model.
* <p>
* <strong>Warning:</strong>
* 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 JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Jeff Dinkins
*/
/** The bitmask used to store the state of the button. */
/** The action command string fired by the button. */
/** The button group that the button belongs to. */
/** The button's mnemonic. */
/**
* Only one <code>ChangeEvent</code> is needed per button model
* instance since the event's only state is the source property.
* The source of events generated is always "this".
*/
/** Stores the listeners on this model. */
// controls the usage of the MenuItem.disabledAreNavigable UIDefaults
// property in the setArmed() method
private boolean menuItem = false;
/**
* Constructs a <code>DefaultButtonModel</code>.
*
*/
public DefaultButtonModel() {
stateMask = 0;
setEnabled(true);
}
/**
* Identifies the "armed" bit in the bitmask, which
* indicates partial commitment towards choosing/triggering
* the button.
*/
/**
* 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.
*/
/**
* Identifies the "pressed" bit in the bitmask, which
* indicates that the button is pressed.
*/
/**
* Identifies the "enabled" bit in the bitmask, which
* indicates that the button can be selected by
* an input device (such as a mouse pointer).
*/
/**
* Identifies the "rollover" bit in the bitmask, which
* indicates that the mouse is over the button.
*/
/**
* {@inheritDoc}
*/
this.actionCommand = actionCommand;
}
/**
* {@inheritDoc}
*/
return actionCommand;
}
/**
* {@inheritDoc}
*/
public boolean isArmed() {
}
/**
* {@inheritDoc}
*/
public boolean isSelected() {
}
/**
* {@inheritDoc}
*/
public boolean isEnabled() {
}
/**
* {@inheritDoc}
*/
public boolean isPressed() {
}
/**
* {@inheritDoc}
*/
public boolean isRollover() {
}
/**
* {@inheritDoc}
*/
public void setArmed(boolean b) {
if(isMenuItem() &&
if ((isArmed() == b)) {
return;
}
} else {
return;
}
}
if (b) {
} else {
}
}
/**
* {@inheritDoc}
*/
public void setEnabled(boolean b) {
if(isEnabled() == b) {
return;
}
if (b) {
} else {
// unarm and unpress, just in case
}
}
/**
* {@inheritDoc}
*/
public void setSelected(boolean b) {
if (this.isSelected() == b) {
return;
}
if (b) {
} else {
}
new ItemEvent(this,
this,
}
/**
* {@inheritDoc}
*/
public void setPressed(boolean b) {
return;
}
if (b) {
} else {
}
int modifiers = 0;
if (currentEvent instanceof InputEvent) {
} else if (currentEvent instanceof ActionEvent) {
}
modifiers));
}
}
/**
* {@inheritDoc}
*/
public void setRollover(boolean b) {
if((isRollover() == b) || !isEnabled()) {
return;
}
if (b) {
} else {
}
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
public int getMnemonic() {
return mnemonic;
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
}
/**
* Returns an array of all the change listeners
* registered on this <code>DefaultButtonModel</code>.
*
* @return all of this model's <code>ChangeListener</code>s
* or an empty
* array if no change listeners are currently registered
*
* @see #addChangeListener
* @see #removeChangeListener
*
* @since 1.4
*/
}
/**
* Notifies all listeners that have registered interest for
* notification on this event type. The event instance
* is created lazily.
*
* @see EventListenerList
*/
protected void fireStateChanged() {
// Guaranteed to return a non-null array
// Process the listeners last to first, notifying
// those that are interested in this event
if (listeners[i]==ChangeListener.class) {
// Lazily create the event:
if (changeEvent == null)
changeEvent = new ChangeEvent(this);
}
}
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
}
/**
* Returns an array of all the action listeners
* registered on this <code>DefaultButtonModel</code>.
*
* @return all of this model's <code>ActionListener</code>s
* or an empty
* array if no action listeners are currently registered
*
* @see #addActionListener
* @see #removeActionListener
*
* @since 1.4
*/
}
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
* @param e the <code>ActionEvent</code> to deliver to listeners
* @see EventListenerList
*/
// Guaranteed to return a non-null array
// Process the listeners last to first, notifying
// those that are interested in this event
if (listeners[i]==ActionListener.class) {
// Lazily create the event:
// if (changeEvent == null)
// changeEvent = new ChangeEvent(this);
}
}
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
}
/**
* Returns an array of all the item listeners
* registered on this <code>DefaultButtonModel</code>.
*
* @return all of this model's <code>ItemListener</code>s
* or an empty
* array if no item listeners are currently registered
*
* @see #addItemListener
* @see #removeItemListener
*
* @since 1.4
*/
}
/**
* Notifies all listeners that have registered interest for
* notification on this event type.
*
* @param e the <code>ItemEvent</code> to deliver to listeners
* @see EventListenerList
*/
// Guaranteed to return a non-null array
// Process the listeners last to first, notifying
// those that are interested in this event
if (listeners[i]==ItemListener.class) {
// Lazily create the event:
// if (changeEvent == null)
// changeEvent = new ChangeEvent(this);
}
}
}
/**
* Returns an array of all the objects currently registered as
* <code><em>Foo</em>Listener</code>s
* upon this model.
* <code><em>Foo</em>Listener</code>s
* are registered using the <code>add<em>Foo</em>Listener</code> method.
* <p>
* You can specify the <code>listenerType</code> argument
* with a class literal, such as <code><em>Foo</em>Listener.class</code>.
* For example, you can query a <code>DefaultButtonModel</code>
* instance <code>m</code>
* for its action listeners
* with the following code:
*
* <pre>ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));</pre>
*
* If no such listeners exist,
* this method returns an empty array.
*
* @param listenerType the type of listeners requested;
* this parameter should specify an interface
* that descends from <code>java.util.EventListener</code>
* @return an array of all objects registered as
* <code><em>Foo</em>Listener</code>s
* on this model,
* or an empty array if no such
* listeners have been added
* @exception ClassCastException if <code>listenerType</code> doesn't
* specify a class or interface that implements
* <code>java.util.EventListener</code>
*
* @see #getActionListeners
* @see #getChangeListeners
* @see #getItemListeners
*
* @since 1.3
*/
}
/** Overridden to return <code>null</code>. */
return null;
}
/**
* {@inheritDoc}
*/
}
/**
* Returns the group that the button belongs to.
* Normally used with radio buttons, which are mutually
* exclusive within their group.
*
* @return the <code>ButtonGroup</code> that the button belongs to
*
* @since 1.3
*/
return group;
}
boolean isMenuItem() {
return menuItem;
}
}
}