jdk/src/share/classes/javax/swing/DefaultButtonModel.java
author rriggs
Tue, 03 Jun 2014 11:18:03 -0400
changeset 25122 1ecc464c69d2
parent 22574 7f8ce0c8c20a
child 24983 f5a6e2ed8c7d
permissions -rw-r--r--
8044460: Cleanup new Boolean and single character strings Reviewed-by: pchelko, serb, rriggs Contributed-by: otaviopolianasantana@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.EventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * The default implementation of a <code>Button</code> component's data model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * the same version of Swing. As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 5506
diff changeset
    42
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @author Jeff Dinkins
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
    48
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class DefaultButtonModel implements ButtonModel, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /** The bitmask used to store the state of the button. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    protected int stateMask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /** The action command string fired by the button. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    protected String actionCommand = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /** The button group that the button belongs to. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    protected ButtonGroup group = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /** The button's mnemonic. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    protected int mnemonic = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * Only one <code>ChangeEvent</code> is needed per button model
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * instance since the event's only state is the source property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * The source of events generated is always "this".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    protected transient ChangeEvent changeEvent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /** Stores the listeners on this model. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    protected EventListenerList listenerList = new EventListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // controls the usage of the MenuItem.disabledAreNavigable UIDefaults
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    // property in the setArmed() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private boolean menuItem = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Constructs a <code>DefaultButtonModel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public DefaultButtonModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        stateMask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        setEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Identifies the "armed" bit in the bitmask, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * indicates partial commitment towards choosing/triggering
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * the button.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public final static int ARMED = 1 << 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Identifies the "selected" bit in the bitmask, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * indicates that the button has been selected. Only needed for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * certain types of buttons - such as radio button or check box.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public final static int SELECTED = 1 << 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Identifies the "pressed" bit in the bitmask, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * indicates that the button is pressed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public final static int PRESSED = 1 << 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Identifies the "enabled" bit in the bitmask, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * indicates that the button can be selected by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * an input device (such as a mouse pointer).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public final static int ENABLED = 1 << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Identifies the "rollover" bit in the bitmask, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * indicates that the mouse is over the button.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public final static int ROLLOVER = 1 << 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public void setActionCommand(String actionCommand) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        this.actionCommand = actionCommand;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public String getActionCommand() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        return actionCommand;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public boolean isArmed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return (stateMask & ARMED) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public boolean isSelected() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        return (stateMask & SELECTED) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return (stateMask & ENABLED) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public boolean isPressed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        return (stateMask & PRESSED) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public boolean isRollover() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return (stateMask & ROLLOVER) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public void setArmed(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if(isMenuItem() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                UIManager.getBoolean("MenuItem.disabledAreNavigable")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            if ((isArmed() == b)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            if ((isArmed() == b) || !isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        if (b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            stateMask |= ARMED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            stateMask &= ~ARMED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        fireStateChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if(isEnabled() == b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        if (b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            stateMask |= ENABLED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            stateMask &= ~ENABLED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            // unarm and unpress, just in case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            stateMask &= ~ARMED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            stateMask &= ~PRESSED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        fireStateChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public void setSelected(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        if (this.isSelected() == b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            stateMask |= SELECTED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            stateMask &= ~SELECTED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        fireItemStateChanged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                new ItemEvent(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                              ItemEvent.ITEM_STATE_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                              this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                              b ?  ItemEvent.SELECTED : ItemEvent.DESELECTED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        fireStateChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public void setPressed(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        if((isPressed() == b) || !isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        if (b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            stateMask |= PRESSED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            stateMask &= ~PRESSED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if(!isPressed() && isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            int modifiers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            AWTEvent currentEvent = EventQueue.getCurrentEvent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            if (currentEvent instanceof InputEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                modifiers = ((InputEvent)currentEvent).getModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            } else if (currentEvent instanceof ActionEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                modifiers = ((ActionEvent)currentEvent).getModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            fireActionPerformed(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                                getActionCommand(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                                EventQueue.getMostRecentEventTime(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                                modifiers));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        fireStateChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    public void setRollover(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        if((isRollover() == b) || !isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if (b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            stateMask |= ROLLOVER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            stateMask &= ~ROLLOVER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        fireStateChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public void setMnemonic(int key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        mnemonic = key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        fireStateChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    public int getMnemonic() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        return mnemonic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    public void addChangeListener(ChangeListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        listenerList.add(ChangeListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public void removeChangeListener(ChangeListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        listenerList.remove(ChangeListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * Returns an array of all the change listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * registered on this <code>DefaultButtonModel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @return all of this model's <code>ChangeListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *         or an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *         array if no change listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @see #addChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @see #removeChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    public ChangeListener[] getChangeListeners() {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   330
        return listenerList.getListeners(ChangeListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * notification on this event type.  The event instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * is created lazily.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    protected void fireStateChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            if (listeners[i]==ChangeListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                if (changeEvent == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                    changeEvent = new ChangeEvent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                ((ChangeListener)listeners[i+1]).stateChanged(changeEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    public void addActionListener(ActionListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        listenerList.add(ActionListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public void removeActionListener(ActionListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        listenerList.remove(ActionListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * Returns an array of all the action listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * registered on this <code>DefaultButtonModel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @return all of this model's <code>ActionListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     *         or an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *         array if no action listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @see #addActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @see #removeActionListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public ActionListener[] getActionListeners() {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   383
        return listenerList.getListeners(ActionListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @param e the <code>ActionEvent</code> to deliver to listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    protected void fireActionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            if (listeners[i]==ActionListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                // if (changeEvent == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                // changeEvent = new ChangeEvent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                ((ActionListener)listeners[i+1]).actionPerformed(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    public void addItemListener(ItemListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        listenerList.add(ItemListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    public void removeItemListener(ItemListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        listenerList.remove(ItemListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * Returns an array of all the item listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * registered on this <code>DefaultButtonModel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * @return all of this model's <code>ItemListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *         or an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *         array if no item listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @see #addItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @see #removeItemListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    public ItemListener[] getItemListeners() {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   436
        return listenerList.getListeners(ItemListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * Notifies all listeners that have registered interest for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * notification on this event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @param e the <code>ItemEvent</code> to deliver to listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @see EventListenerList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    protected void fireItemStateChanged(ItemEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        // Guaranteed to return a non-null array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        // Process the listeners last to first, notifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        // those that are interested in this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        for (int i = listeners.length-2; i>=0; i-=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            if (listeners[i]==ItemListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                // Lazily create the event:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                // if (changeEvent == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                // changeEvent = new ChangeEvent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                ((ItemListener)listeners[i+1]).itemStateChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * Returns an array of all the objects currently registered as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * <code><em>Foo</em>Listener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * upon this model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * <code><em>Foo</em>Listener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * are registered using the <code>add<em>Foo</em>Listener</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * You can specify the <code>listenerType</code> argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * with a class literal, such as <code><em>Foo</em>Listener.class</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * For example, you can query a <code>DefaultButtonModel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * instance <code>m</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * for its action listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * with the following code:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * <pre>ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * If no such listeners exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * this method returns an empty array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * @param listenerType  the type of listeners requested;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     *          this parameter should specify an interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     *          that descends from <code>java.util.EventListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @return an array of all objects registered as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *          <code><em>Foo</em>Listener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *          on this model,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *          or an empty array if no such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     *          listeners have been added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @exception ClassCastException if <code>listenerType</code> doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     *          specify a class or interface that implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *          <code>java.util.EventListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @see #getActionListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @see #getChangeListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @see #getItemListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        return listenerList.getListeners(listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    /** Overridden to return <code>null</code>. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    public Object[] getSelectedObjects() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    public void setGroup(ButtonGroup group) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        this.group = group;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * Returns the group that the button belongs to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * Normally used with radio buttons, which are mutually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * exclusive within their group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @return the <code>ButtonGroup</code> that the button belongs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    public ButtonGroup getGroup() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        return group;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    boolean isMenuItem() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        return menuItem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    void setMenuItem(boolean menuItem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        this.menuItem = menuItem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
}