3909N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Defines common behaviors for buttons and menu items. 0N/A * Buttons can be configured, and to some degree controlled, by 0N/A * <code>Action</code> with a button has many benefits beyond directly 0N/A * Swing Components Supporting <code>Action</code></a> for more 0N/A * details, and you can find more information in <a 0N/A * to Use Actions</a>, a section in <em>The Java Tutorial</em>. 0N/A * For further information see 0N/A * a section in <em>The Java Tutorial</em>. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * @author Jeff Dinkins 0N/A // ********************************* 0N/A // ******* Button properties ******* 0N/A // ********************************* 0N/A /** Identifies a change in the button model. */ 0N/A /** Identifies a change in the button's text. */ 0N/A /** Identifies a change to the button's mnemonic. */ 0N/A // Text positioning and alignment 0N/A /** Identifies a change in the button's margins. */ 0N/A /** Identifies a change in the button's vertical alignment. */ 0N/A /** Identifies a change in the button's horizontal alignment. */ 0N/A /** Identifies a change in the button's vertical text position. */ 0N/A /** Identifies a change in the button's horizontal text position. */ 0N/A * Identifies a change to having the border drawn, 0N/A * or having it not drawn. 0N/A * Identifies a change to having the border highlighted when focused, 0N/A * Identifies a change from rollover enabled to disabled or back 0N/A * Identifies a change to having the button paint the content area. 0N/A /** Identifies a change to the icon that represents the button. */ 0N/A * Identifies a change to the icon used when the button has been 0N/A * Identifies a change to the icon used when the button has 0N/A * Identifies a change to the icon used when the cursor is over 0N/A * Identifies a change to the icon used when the cursor is 0N/A * over the button and it has been selected. 0N/A * Identifies a change to the icon used when the button has 0N/A * Identifies a change to the icon used when the button has been 0N/A * disabled and selected. 0N/A /** The data model that determines the button's state. */ 0N/A // PENDING(jeff) - hold icons in an array 0N/A // Display properties 0N/A // Whether or not we've set the LayoutManager. 0N/A // This is only used by JButton, promoted to avoid an extra 0N/A // boolean field in JButton 0N/A * Combined listeners: ActionListener, ChangeListener, ItemListener. 0N/A * The button model's <code>changeListener</code>. 0N/A * The button model's <code>ActionListener</code>. 0N/A * The button model's <code>ItemListener</code>. 0N/A * Only one <code>ChangeEvent</code> is needed per button 0N/A * instance since the 0N/A * event's only state is the source property. The source of events 0N/A * generated is always "this". 0N/A * Sets the <code>hideActionText</code> property, which determines 0N/A * whether the button displays text from the <code>Action</code>. 0N/A * This is useful only if an <code>Action</code> has been 0N/A * installed on the button. 0N/A * @param hideActionText <code>true</code> if the button's 0N/A * <code>text</code> property should not reflect 0N/A * that of the <code>Action</code>; the default is 0N/A * <code>false</code> 0N/A * @see <a href="Action.html#buttonActions">Swing Components Supporting 0N/A * <code>Action</code></a> 0N/A * description: Whether the text of the button should come from 0N/A * the <code>Action</code>. 0N/A * Returns the value of the <code>hideActionText</code> property, which 0N/A * determines whether the button displays text from the 0N/A * <code>Action</code>. This is useful only if an <code>Action</code> 0N/A * has been installed on the button. 0N/A * @return <code>true</code> if the button's <code>text</code> 0N/A * property should not reflect that of the 0N/A * <code>Action</code>; the default is <code>false</code> 0N/A * Returns the button's text. 0N/A * @return the buttons text 0N/A * Sets the button's text. 0N/A * @param text the string used to set the text 0N/A * attribute: visualUpdate true 0N/A * description: The button's text. 0N/A * Returns the state of the button. True if the 0N/A * toggle button is selected, false if it's not. 0N/A * @return true if the toggle button is selected, otherwise false 0N/A * Sets the state of the button. Note that this method does not 0N/A * trigger an <code>actionEvent</code>. 0N/A * Call <code>doClick</code> to perform a programatic action change. 0N/A * @param b true if the button is selected, otherwise false 0N/A // Removed code which fired an AccessibleState.SELECTED 0N/A // PropertyChangeEvent since this resulted in two 0N/A // identical events being fired since 0N/A // AbstractButton.fireItemStateChanged also fires the 0N/A // same event. This caused screen readers to speak the 0N/A // name of the item twice. 0N/A * Programmatically perform a "click". This does the same 0N/A * thing as if the user had pressed and released the button. 0N/A * Programmatically perform a "click". This does the same 0N/A * thing as if the user had pressed and released the button. 0N/A * The button stays visually "pressed" for <code>pressTime</code> 0N/A * @param pressTime the time to "hold down" the button, in milliseconds 0N/A * Sets space for margin between the button's border and 0N/A * the label. Setting to <code>null</code> will cause the button to 0N/A * use the default margin. The button's default <code>Border</code> 0N/A * object will use this value to create the proper margin. 0N/A * However, if a non-default border is set on the button, 0N/A * it is that <code>Border</code> object's responsibility to create the 0N/A * appropriate margin space (else this property will 0N/A * effectively be ignored). 0N/A * @param m the space between the border and the label 0N/A * attribute: visualUpdate true 0N/A * description: The space between the button's border and the label. 0N/A // Cache the old margin if it comes from the UI 0N/A // If the client passes in a null insets, restore the margin 0N/A // from the UI if possible 0N/A * Returns the margin between the button's border and 0N/A * @return an <code>Insets</code> object specifying the margin 0N/A * between the botton's border and the label 0N/A * Returns the default icon. 0N/A * @return the default <code>Icon</code> 0N/A * Sets the button's default icon. This icon is 0N/A * also used as the "pressed" and "disabled" icon if 0N/A * there is no explicitly set pressed icon. 0N/A * @param defaultIcon the icon used as the default image 0N/A * @see #setPressedIcon 0N/A * attribute: visualUpdate true 0N/A * description: The button's default icon 0N/A /* If the default icon has really changed and we had 0N/A * generated the disabled icon for this component, 0N/A * (i.e. setDisabledIcon() was never called) then 0N/A * clear the disabledIcon field. 0N/A * Returns the pressed icon for the button. 0N/A * @return the <code>pressedIcon</code> property 0N/A * @see #setPressedIcon 0N/A * Sets the pressed icon for the button. 0N/A * @param pressedIcon the icon used as the "pressed" image 0N/A * @see #getPressedIcon 0N/A * attribute: visualUpdate true 0N/A * description: The pressed icon for the button. 0N/A * Returns the selected icon for the button. 0N/A * @return the <code>selectedIcon</code> property 0N/A * @see #setSelectedIcon 0N/A * Sets the selected icon for the button. 0N/A * @param selectedIcon the icon used as the "selected" image 0N/A * @see #getSelectedIcon 0N/A * attribute: visualUpdate true 0N/A * description: The selected icon for the button. 0N/A /* If the default selected icon has really changed and we had 0N/A * generated the disabled selected icon for this component, 0N/A * (i.e. setDisabledSelectedIcon() was never called) then 0N/A * clear the disabledSelectedIcon field. 0N/A * Returns the rollover icon for the button. 0N/A * @return the <code>rolloverIcon</code> property 0N/A * @see #setRolloverIcon 0N/A * Sets the rollover icon for the button. 0N/A * @param rolloverIcon the icon used as the "rollover" image 0N/A * @see #getRolloverIcon 0N/A * attribute: visualUpdate true 0N/A * description: The rollover icon for the button. 0N/A // No way to determine whether we are currently in 0N/A // a rollover state, so repaint regardless 0N/A * Returns the rollover selection icon for the button. 0N/A * @return the <code>rolloverSelectedIcon</code> property 0N/A * @see #setRolloverSelectedIcon 0N/A * Sets the rollover selected icon for the button. 0N/A * @param rolloverSelectedIcon the icon used as the 0N/A * "selected rollover" image 0N/A * @see #getRolloverSelectedIcon 0N/A * attribute: visualUpdate true 0N/A * description: The rollover selected icon for the button. 0N/A // No way to determine whether we are currently in 0N/A // a rollover state, so repaint regardless 0N/A * Returns the icon used by the button when it's disabled. 0N/A * If no disabled icon has been set this will forward the call to 0N/A * the look and feel to construct an appropriate disabled Icon. 0N/A * Some look and feels might not render the disabled Icon, in which 0N/A * case they will ignore this. 0N/A * @return the <code>disabledIcon</code> property 0N/A * @see #getPressedIcon 0N/A * @see #setDisabledIcon 0N/A * @see javax.swing.LookAndFeel#getDisabledIcon 0N/A * Sets the disabled icon for the button. 0N/A * @param disabledIcon the icon used as the disabled image 0N/A * @see #getDisabledIcon 0N/A * attribute: visualUpdate true 0N/A * description: The disabled icon for the button. 0N/A * Returns the icon used by the button when it's disabled and selected. 0N/A * If no disabled selection icon has been set, this will forward 0N/A * the call to the LookAndFeel to construct an appropriate disabled 0N/A * Icon from the selection icon if it has been set and to 0N/A * <code>getDisabledIcon()</code> otherwise. 0N/A * Some look and feels might not render the disabled selected Icon, in 0N/A * which case they will ignore this. 0N/A * @return the <code>disabledSelectedIcon</code> property 0N/A * @see #getDisabledIcon 0N/A * @see #setDisabledSelectedIcon 0N/A * @see javax.swing.LookAndFeel#getDisabledSelectedIcon 0N/A * Sets the disabled selection icon for the button. 0N/A * @param disabledSelectedIcon the icon used as the disabled 0N/A * @see #getDisabledSelectedIcon 0N/A * attribute: visualUpdate true 0N/A * description: The disabled selection icon for the button. 0N/A * Returns the vertical alignment of the text and icon. 0N/A * @return the <code>verticalAlignment</code> property, one of the 0N/A * <li>{@code SwingConstants.CENTER} (the default) 0N/A * <li>{@code SwingConstants.TOP} 0N/A * <li>{@code SwingConstants.BOTTOM} 0N/A * Sets the vertical alignment of the icon and text. 0N/A * @param alignment one of the following values: 0N/A * <li>{@code SwingConstants.CENTER} (the default) 0N/A * <li>{@code SwingConstants.TOP} 0N/A * <li>{@code SwingConstants.BOTTOM} 0N/A * @throws IllegalArgumentException if the alignment is not one of the legal 0N/A * values listed above 0N/A * enum: TOP SwingConstants.TOP 0N/A * CENTER SwingConstants.CENTER 0N/A * BOTTOM SwingConstants.BOTTOM 0N/A * attribute: visualUpdate true 0N/A * description: The vertical alignment of the icon and text. 0N/A * Returns the horizontal alignment of the icon and text. 0N/A * {@code AbstractButton}'s default is {@code SwingConstants.CENTER}, 0N/A * but subclasses such as {@code JCheckBox} may use a different default. 0N/A * @return the <code>horizontalAlignment</code> property, 0N/A * one of the following values: 0N/A * <li>{@code SwingConstants.RIGHT} 0N/A * <li>{@code SwingConstants.LEFT} 0N/A * <li>{@code SwingConstants.CENTER} 0N/A * <li>{@code SwingConstants.LEADING} 0N/A * <li>{@code SwingConstants.TRAILING} 0N/A * Sets the horizontal alignment of the icon and text. 0N/A * {@code AbstractButton}'s default is {@code SwingConstants.CENTER}, 0N/A * but subclasses such as {@code JCheckBox} may use a different default. 0N/A * @param alignment the alignment value, one of the following values: 0N/A * <li>{@code SwingConstants.RIGHT} 0N/A * <li>{@code SwingConstants.LEFT} 0N/A * <li>{@code SwingConstants.CENTER} 0N/A * <li>{@code SwingConstants.LEADING} 0N/A * <li>{@code SwingConstants.TRAILING} 0N/A * @throws IllegalArgumentException if the alignment is not one of the 0N/A * enum: LEFT SwingConstants.LEFT 0N/A * CENTER SwingConstants.CENTER 0N/A * RIGHT SwingConstants.RIGHT 0N/A * LEADING SwingConstants.LEADING 0N/A * TRAILING SwingConstants.TRAILING 0N/A * attribute: visualUpdate true 0N/A * description: The horizontal alignment of the icon and text. 0N/A "horizontalAlignment");
0N/A * Returns the vertical position of the text relative to the icon. 0N/A * @return the <code>verticalTextPosition</code> property, 0N/A * one of the following values: 0N/A * <li>{@code SwingConstants.CENTER} (the default) 0N/A * <li>{@code SwingConstants.TOP} 0N/A * <li>{@code SwingConstants.BOTTOM} 0N/A * Sets the vertical position of the text relative to the icon. 0N/A * @param textPosition one of the following values: 0N/A * <li>{@code SwingConstants.CENTER} (the default) 0N/A * <li>{@code SwingConstants.TOP} 0N/A * <li>{@code SwingConstants.BOTTOM} 0N/A * enum: TOP SwingConstants.TOP 0N/A * CENTER SwingConstants.CENTER 0N/A * BOTTOM SwingConstants.BOTTOM 0N/A * attribute: visualUpdate true 0N/A * description: The vertical position of the text relative to the icon. 0N/A * Returns the horizontal position of the text relative to the icon. 0N/A * @return the <code>horizontalTextPosition</code> property, 0N/A * one of the following values: 0N/A * <li>{@code SwingConstants.RIGHT} 0N/A * <li>{@code SwingConstants.LEFT} 0N/A * <li>{@code SwingConstants.CENTER} 0N/A * <li>{@code SwingConstants.LEADING} 0N/A * <li>{@code SwingConstants.TRAILING} (the default) 0N/A * Sets the horizontal position of the text relative to the icon. 0N/A * @param textPosition one of the following values: 0N/A * <li>{@code SwingConstants.RIGHT} 0N/A * <li>{@code SwingConstants.LEFT} 0N/A * <li>{@code SwingConstants.CENTER} 0N/A * <li>{@code SwingConstants.LEADING} 0N/A * <li>{@code SwingConstants.TRAILING} (the default) 0N/A * @exception IllegalArgumentException if <code>textPosition</code> 0N/A * is not one of the legal values listed above 0N/A * enum: LEFT SwingConstants.LEFT 0N/A * CENTER SwingConstants.CENTER 0N/A * RIGHT SwingConstants.RIGHT 0N/A * LEADING SwingConstants.LEADING 0N/A * TRAILING SwingConstants.TRAILING 0N/A * attribute: visualUpdate true 0N/A * description: The horizontal position of the text relative to the icon. 0N/A "horizontalTextPosition");
0N/A * Returns the amount of space between the text and the icon 0N/A * displayed in this button. 0N/A * @return an int equal to the number of pixels between the text 0N/A * @see #setIconTextGap 0N/A * If both the icon and text properties are set, this property 0N/A * defines the space between them. 0N/A * The default value of this property is 4 pixels. 0N/A * This is a JavaBeans bound property. 0N/A * @see #getIconTextGap 0N/A * attribute: visualUpdate true 0N/A * description: If both the icon and text properties are set, this 0N/A * property defines the space between them. 0N/A * Verify that the {@code key} argument is a legal value for the 0N/A * {@code horizontalAlignment} and {@code horizontalTextPosition} 0N/A * properties. Valid values are: 0N/A * <li>{@code SwingConstants.RIGHT} 0N/A * <li>{@code SwingConstants.LEFT} 0N/A * <li>{@code SwingConstants.CENTER} 0N/A * <li>{@code SwingConstants.LEADING} 0N/A * <li>{@code SwingConstants.TRAILING} 0N/A * @param key the property value to check 0N/A * @param exception the message to use in the 0N/A * {@code IllegalArgumentException} that is thrown for an invalid 0N/A * @exception IllegalArgumentException if key is not one of the legal 0N/A * values listed above 0N/A * @see #setHorizontalTextPosition 0N/A * @see #setHorizontalAlignment 0N/A * Verify that the {@code key} argument is a legal value for the 0N/A * vertical properties. Valid values are: 0N/A * <li>{@code SwingConstants.CENTER} 0N/A * <li>{@code SwingConstants.TOP} 0N/A * <li>{@code SwingConstants.BOTTOM} 0N/A * @param key the property value to check 0N/A * @param exception the message to use in the 0N/A * {@code IllegalArgumentException} that is thrown for an invalid 0N/A * @exception IllegalArgumentException if key is not one of the legal 0N/A * values listed above 0N/A * Sets the action command for this button. 0N/A * @param actionCommand the action command for this button 0N/A * Returns the action command for this button. 0N/A * @return the action command for this button 0N/A * Sets the <code>Action</code>. 0N/A * The new <code>Action</code> replaces any previously set 0N/A * <code>Action</code> but does not affect <code>ActionListeners</code> 0N/A * independently added with <code>addActionListener</code>. 0N/A * If the <code>Action</code> is already a registered 0N/A * <code>ActionListener</code> for the button, it is not re-registered. 0N/A * Setting the <code>Action</code> results in immediately changing 0N/A * all the properties described in <a href="Action.html#buttonActions"> 0N/A * Swing Components Supporting <code>Action</code></a>. 0N/A * Subsequently, the button's properties are automatically updated 0N/A * as the <code>Action</code>'s properties change. 0N/A * This method uses three other methods to set 0N/A * and help track the <code>Action</code>'s property values. 0N/A * It uses the <code>configurePropertiesFromAction</code> method 0N/A * to immediately change the button's properties. 0N/A * To track changes in the <code>Action</code>'s property values, 0N/A * this method registers the <code>PropertyChangeListener</code> 0N/A * returned by <code>createActionPropertyChangeListener</code>. The 0N/A * default {@code PropertyChangeListener} invokes the 0N/A * {@code actionPropertyChanged} method when a property in the 0N/A * {@code Action} changes. 0N/A * @param a the <code>Action</code> for the <code>AbstractButton</code>, 0N/A * or <code>null</code> 0N/A * @see #configurePropertiesFromAction 0N/A * @see #createActionPropertyChangeListener 0N/A * @see #actionPropertyChanged 0N/A * attribute: visualUpdate true 0N/A * description: the Action instance connected with this ActionEvent source 0N/A // Don't add if it is already a listener 0N/A * Returns the currently set <code>Action</code> for this 0N/A * <code>ActionEvent</code> source, or <code>null</code> 0N/A * if no <code>Action</code> is set. 0N/A * @return the <code>Action</code> for this <code>ActionEvent</code> 0N/A * source, or <code>null</code> 0N/A * Sets the properties on this button to match those in the specified 0N/A * Swing Components Supporting <code>Action</code></a> for more 0N/A * details as to which properties this sets. 0N/A * @param a the <code>Action</code> from which to get the properties, 0N/A * or <code>null</code> 0N/A if (
key ==
"hideActionText") {
0N/A * Button subclasses that support mirroring the selected state from 0N/A * the action should override this to return true. AbstractButton's 0N/A * implementation returns false. 0N/A * Updates the button's state in response to property changes in the 0N/A * associated action. This method is invoked from the 0N/A * {@code PropertyChangeListener} returned from 0N/A * {@code createActionPropertyChangeListener}. Subclasses do not normally 0N/A * need to invoke this. Subclasses that support additional {@code Action} 0N/A * properties should override this and 0N/A * {@code configurePropertiesFromAction}. 0N/A * Swing Components Supporting <code>Action</code></a> for a list of 0N/A * the properties this method sets. 0N/A * @param action the <code>Action</code> associated with this button 0N/A * @param propertyName the name of the property that changed 0N/A * @see #configurePropertiesFromAction 0N/A * Sets the seleted state of the button from the action. This is defined 0N/A * here, but not wired up. Subclasses like JToggleButton and 0N/A * JCheckBoxMenuItem make use of it. 0N/A * @param a the Action 0N/A // This won't notify ActionListeners, but that should be 0N/A // ok as the change is coming from the Action. 0N/A // Make sure the change actually took effect 0N/A * Creates and returns a <code>PropertyChangeListener</code> that is 0N/A * responsible for listening for changes from the specified 0N/A * <code>Action</code> and updating the appropriate properties. 0N/A * <b>Warning:</b> If you subclass this do not create an anonymous 0N/A * inner class. If you do the lifetime of the button will be tied to 0N/A * that of the <code>Action</code>. 0N/A * @param a the button's action 0N/A * Gets the <code>borderPainted</code> property. 0N/A * @return the value of the <code>borderPainted</code> property 0N/A * @see #setBorderPainted 0N/A * Sets the <code>borderPainted</code> property. 0N/A * If <code>true</code> and the button has a border, 0N/A * the border is painted. The default value for the 0N/A * <code>borderPainted</code> property is <code>true</code>. 3095N/A * Some look and feels might not support 3095N/A * the <code>borderPainted</code> property, 3095N/A * in which case they ignore this. 0N/A * @param b if true and border property is not <code>null</code>, 0N/A * the border is painted 0N/A * @see #isBorderPainted 0N/A * attribute: visualUpdate true 0N/A * description: Whether the border should be painted. 0N/A * Paint the button's border if <code>BorderPainted</code> 0N/A * property is true and the button has a border. 0N/A * @param g the <code>Graphics</code> context in which to paint 0N/A * Gets the <code>paintFocus</code> property. 0N/A * @return the <code>paintFocus</code> property 0N/A * @see #setFocusPainted 0N/A * Sets the <code>paintFocus</code> property, which must 0N/A * be <code>true</code> for the focus state to be painted. 0N/A * The default value for the <code>paintFocus</code> property 0N/A * is <code>true</code>. 0N/A * Some look and feels might not paint focus state; 0N/A * they will ignore this property. 0N/A * @param b if <code>true</code>, the focus state should be painted 0N/A * @see #isFocusPainted 0N/A * attribute: visualUpdate true 0N/A * description: Whether focus should be painted 0N/A * Gets the <code>contentAreaFilled</code> property. 0N/A * @return the <code>contentAreaFilled</code> property 0N/A * @see #setContentAreaFilled 0N/A * Sets the <code>contentAreaFilled</code> property. 0N/A * If <code>true</code> the button will paint the content 0N/A * area. If you wish to have a transparent button, such as 0N/A * an icon only button, for example, then you should set 0N/A * this to <code>false</code>. Do not call <code>setOpaque(false)</code>. 0N/A * The default value for the the <code>contentAreaFilled</code> 0N/A * property is <code>true</code>. 0N/A * This function may cause the component's opaque property to change. 0N/A * The exact behavior of calling this function varies on a 0N/A * component-by-component and L&F-by-L&F basis. 0N/A * @param b if true, the content should be filled; if false 0N/A * the content area is not filled 0N/A * @see #isContentAreaFilled 0N/A * attribute: visualUpdate true 0N/A * description: Whether the button should paint the content area 0N/A * or leave it transparent. 0N/A * Gets the <code>rolloverEnabled</code> property. 0N/A * @return the value of the <code>rolloverEnabled</code> property 0N/A * @see #setRolloverEnabled 0N/A * Sets the <code>rolloverEnabled</code> property, which 0N/A * must be <code>true</code> for rollover effects to occur. 0N/A * The default value for the <code>rolloverEnabled</code> 0N/A * property is <code>false</code>. 0N/A * Some look and feels might not implement rollover effects; 0N/A * they will ignore this property. 0N/A * @param b if <code>true</code>, rollover effects should be painted 0N/A * @see #isRolloverEnabled 0N/A * attribute: visualUpdate true 0N/A * description: Whether rollover effects should be enabled. 0N/A * Returns the keyboard mnemonic from the the current model. 0N/A * @return the keyboard mnemonic from the model 0N/A * Sets the keyboard mnemonic on the current model. 0N/A * The mnemonic is the key which when combined with the look and feel's 0N/A * mouseless modifier (usually Alt) will activate this button 0N/A * if focus is contained somewhere within this button's ancestor 0N/A * A mnemonic must correspond to a single key on the keyboard 0N/A * and should be specified using one of the <code>VK_XXX</code> 0N/A * keycodes defined in <code>java.awt.event.KeyEvent</code>. 1067N/A * These codes and the wider array of codes for international 1067N/A * keyboards may be obtained through 1067N/A * <code>java.awt.event.KeyEvent.getExtendedKeyCodeForChar</code>. 0N/A * Mnemonics are case-insensitive, therefore a key event 0N/A * with the corresponding keycode would cause the button to be 0N/A * activated whether or not the Shift modifier was pressed. 0N/A * If the character defined by the mnemonic is found within 0N/A * the button's label string, the first occurrence of it 0N/A * will be underlined to indicate the mnemonic to the user. 0N/A * @param mnemonic the key code which represents the mnemonic 0N/A * @see java.awt.event.KeyEvent 0N/A * @see #setDisplayedMnemonicIndex 0N/A * attribute: visualUpdate true 0N/A * description: the keyboard character mnemonic 0N/A * This method is now obsolete, please use <code>setMnemonic(int)</code> 0N/A * to set the mnemonic for a button. This method is only designed 0N/A * to handle character values which fall between 'a' and 'z' or 0N/A * @param mnemonic a char specifying the mnemonic value 0N/A * @see #setMnemonic(int) 0N/A * attribute: visualUpdate true 0N/A * description: the keyboard character mnemonic 0N/A * Provides a hint to the look and feel as to which character in the 0N/A * text should be decorated to represent the mnemonic. Not all look and 0N/A * feels may support this. A value of -1 indicates either there is no 0N/A * mnemonic, the mnemonic character is not contained in the string, or 0N/A * the developer does not wish the mnemonic to be displayed. 0N/A * The value of this is updated as the properties relating to the 0N/A * mnemonic change (such as the mnemonic itself, the text...). 0N/A * You should only ever have to call this if 0N/A * you do not wish the default character to be underlined. For example, if 0N/A * the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A' 0N/A * to be decorated, as 'Save <u>A</u>s', you would have to invoke 0N/A * <code>setDisplayedMnemonicIndex(5)</code> after invoking 0N/A * <code>setMnemonic(KeyEvent.VK_A)</code>. 0N/A * @param index Index into the String to underline 0N/A * @exception IllegalArgumentException will be thrown if <code>index</code> 0N/A * is >= length of the text, or < -1 0N/A * @see #getDisplayedMnemonicIndex 0N/A * attribute: visualUpdate true 0N/A * description: the index into the String to draw the keyboard character 0N/A * Returns the character, as an index, that the look and feel should 0N/A * provide decoration for as representing the mnemonic character. 0N/A * @return index representing mnemonic character 0N/A * @see #setDisplayedMnemonicIndex 0N/A * Update the displayedMnemonicIndex property. This method 0N/A * is called when either text or mnemonic changes. The new 0N/A * value of the displayedMnemonicIndex property is the index 0N/A * of the first occurrence of mnemonic in text. 0N/A * Brings the mnemonic property in accordance with model's mnemonic. 0N/A * This is called when model's mnemonic changes. Also updates the 0N/A * displayedMnemonicIndex property. 0N/A * Sets the amount of time (in milliseconds) required between 0N/A * mouse press events for the button to generate the corresponding 0N/A * action events. After the initial mouse press occurs (and action 0N/A * event generated) any subsequent mouse press events which occur 0N/A * on intervals less than the threshhold will be ignored and no 0N/A * corresponding action event generated. By default the threshhold is 0, 0N/A * which means that for each mouse press, an action event will be 0N/A * fired, no matter how quickly the mouse clicks occur. In buttons 0N/A * where this behavior is not desirable (for example, the "OK" button 0N/A * in a dialog), this threshhold should be set to an appropriate 0N/A * @see #getMultiClickThreshhold 0N/A * @param threshhold the amount of time required between mouse 0N/A * press events to generate corresponding action events 0N/A * @exception IllegalArgumentException if threshhold < 0 0N/A * Gets the amount of time (in milliseconds) required between 0N/A * mouse press events for the button to generate the corresponding 0N/A * @see #setMultiClickThreshhold 0N/A * @return the amount of time required between mouse press events 0N/A * to generate corresponding action events 0N/A * Returns the model that this button represents. 0N/A * @return the <code>model</code> property 0N/A * Sets the model that this button represents. 0N/A * @param newModel the new <code>ButtonModel</code> 0N/A * description: Model that the Button uses. 0N/A //We invoke setEnabled() from JComponent 0N/A //because setModel() can be called from a constructor 0N/A //when the button is not fully initialized 0N/A * Returns the L&F object that renders this component. 0N/A * @return the ButtonUI object 0N/A * Sets the L&F object that renders this component. 0N/A * @param ui the <code>ButtonUI</code> L&F object 0N/A * attribute: visualUpdate true 0N/A * description: The UI object that implements the LookAndFeel. 0N/A // disabled icons are generated by the LF so they should be unset here 0N/A * Resets the UI property to a value from the current look 0N/A * and feel. Subtypes of <code>AbstractButton</code> 0N/A * should override this to update the UI. For 0N/A * example, <code>JButton</code> might do the following: 0N/A * setUI((ButtonUI)UIManager.getUI( 0N/A * "ButtonUI", "javax.swing.plaf.basic.BasicButtonUI", this)); 0N/A * Adds the specified component to this container at the specified 0N/A * {@link java.awt.Container#addImpl(Component, Object, int)} 0N/A * for a complete description of this method. 0N/A * @param comp the component to be added 0N/A * @param constraints an object expressing layout constraints 0N/A * for this component 0N/A * @param index the position in the container's list at which to 0N/A * insert the component, where <code>-1</code> 0N/A * means append to the end 0N/A * @exception IllegalArgumentException if <code>index</code> is invalid 0N/A * @exception IllegalArgumentException if adding the container's parent 0N/A * @exception IllegalArgumentException if adding a window to a container 0N/A * Sets the layout manager for this container, refer to 0N/A * {@link java.awt.Container#setLayout(LayoutManager)} 0N/A * for a complete description of this method. 0N/A * @param mgr the specified layout manager 0N/A * Adds a <code>ChangeListener</code> to the button. 0N/A * @param l the listener to be added 0N/A * Removes a ChangeListener from the button. 0N/A * @param l the listener to be removed 0N/A * Returns an array of all the <code>ChangeListener</code>s added 0N/A * to this AbstractButton with addChangeListener(). 0N/A * @return all of the <code>ChangeListener</code>s added or an empty 0N/A * array if no listeners have been added 0N/A * Notifies all listeners that have registered interest for 0N/A * notification on this event type. The event instance 0N/A * is lazily created. 0N/A * @see EventListenerList 0N/A // Guaranteed to return a non-null array 0N/A // Process the listeners last to first, notifying 0N/A // those that are interested in this event 0N/A // Lazily create the event: 0N/A * Adds an <code>ActionListener</code> to the button. 0N/A * @param l the <code>ActionListener</code> to be added 0N/A * Removes an <code>ActionListener</code> from the button. 0N/A * If the listener is the currently set <code>Action</code> 0N/A * for the button, then the <code>Action</code> 0N/A * is set to <code>null</code>. 0N/A * @param l the listener to be removed 0N/A * Returns an array of all the <code>ActionListener</code>s added 0N/A * to this AbstractButton with addActionListener(). 0N/A * @return all of the <code>ActionListener</code>s added or an empty 0N/A * array if no listeners have been added 0N/A * Subclasses that want to handle <code>ChangeEvents</code> differently 0N/A * can override this to return another <code>ChangeListener</code> 0N/A * @return the new <code>ChangeListener</code> 0N/A * Extends <code>ChangeListener</code> to be serializable. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A // NOTE: This class is NOT used, instead the functionality has 0N/A // been moved to Handler. 0N/A * Notifies all listeners that have registered interest for 0N/A * notification on this event type. The event instance 0N/A * is lazily created using the <code>event</code> 0N/A * @param event the <code>ActionEvent</code> object 0N/A * @see EventListenerList 0N/A // Guaranteed to return a non-null array 0N/A // Process the listeners last to first, notifying 0N/A // those that are interested in this event 0N/A // Lazily create the event: 0N/A * Notifies all listeners that have registered interest for 0N/A * notification on this event type. The event instance 0N/A * is lazily created using the <code>event</code> parameter. 0N/A * @param event the <code>ItemEvent</code> object 0N/A * @see EventListenerList 0N/A // Guaranteed to return a non-null array 0N/A // Process the listeners last to first, notifying 0N/A // those that are interested in this event 0N/A // Lazily create the event: 0N/A * Enables (or disables) the button. 0N/A * @param b true to enable the button, otherwise false 0N/A // *** Deprecated java.awt.Button APIs below *** // 0N/A * Returns the label text. 0N/A * @return a <code>String</code> containing the label 0N/A * @deprecated - Replaced by <code>getText</code> 0N/A * Sets the label text. 0N/A * @param label a <code>String</code> containing the text 0N/A * @deprecated - Replaced by <code>setText(text)</code> 0N/A * description: Replace by setText(text) 0N/A * Adds an <code>ItemListener</code> to the <code>checkbox</code>. 0N/A * @param l the <code>ItemListener</code> to be added 0N/A * Removes an <code>ItemListener</code> from the button. 0N/A * @param l the <code>ItemListener</code> to be removed 0N/A * Returns an array of all the <code>ItemListener</code>s added 0N/A * to this AbstractButton with addItemListener(). 0N/A * @return all of the <code>ItemListener</code>s added or an empty 0N/A * array if no listeners have been added 0N/A * Returns an array (length 1) containing the label or 0N/A * <code>null</code> if the button is not selected. 0N/A * @return an array containing 1 Object: the text of the button, 0N/A * if the item is selected; otherwise <code>null</code> 0N/A * This is overridden to return false if the current <code>Icon</code>'s 0N/A * <code>Image</code> is not equal to the 0N/A * passed in <code>Image</code> <code>img</code>. 0N/A * @param img the <code>Image</code> to be compared 0N/A * @param infoflags flags used to repaint the button when the image 0N/A * is updated and which determine how much is to be painted 0N/A * @param x the x coordinate 0N/A * @param y the y coordinate 0N/A * @param w the width 0N/A * @param h the height 0N/A * @see java.awt.image.ImageObserver 0N/A * @see java.awt.Component#imageUpdate(java.awt.Image, int, int, int, int, int) 0N/A int x,
int y,
int w,
int h) {
0N/A // We don't know about this image, disable the notification so 0N/A // we don't keep repainting. 0N/A * Returns a string representation of this <code>AbstractButton</code>. 0N/A * is intended to be used only for debugging purposes, and the 0N/A * content and format of the returned string may vary between 0N/A * implementations. The returned string may be empty but may not 0N/A * be <code>null</code>. 0N/A * Overriding <code>paramString</code> to provide information about the 0N/A * specific new aspects of the JFC components. 0N/A * @return a string representation of this <code>AbstractButton</code> 0N/A // Listeners that are added to model 0N/A// Accessibility support 0N/A * This class implements accessibility support for the 0N/A * <code>AbstractButton</code> class. It provides an implementation of the 0N/A * Java Accessibility API appropriate to button and menu item 0N/A * user-interface elements. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * Returns the accessible name of this object. 0N/A * @return the localized name of the object -- can be 0N/A * <code>null</code> if this 0N/A * object does not have a name 0N/A * Get the AccessibleIcons associated with this object if one 0N/A * or more exist. Otherwise return null. 0N/A * Get the state set of this object. 0N/A * @return an instance of AccessibleState containing the current state 0N/A * @see AccessibleState 0N/A * Get the AccessibleRelationSet associated with this object if one 0N/A * exists. Otherwise return null. 0N/A * @see AccessibleRelation 0N/A // Check where the AccessibleContext's relation 0N/A // set already contains a MEMBER_OF relation. 0N/A // get the members of the button group if one exists 0N/A // set the target of the MEMBER_OF relation to be 0N/A // the members of the button group. 0N/A for (
int i =
0; i <
len; i++) {
0N/A * Get the AccessibleAction associated with this object. In the 0N/A * implementation of the Java Accessibility API for this class, 0N/A * return this object, which is responsible for implementing the 0N/A * AccessibleAction interface on behalf of itself. 0N/A * @return this object 0N/A * Get the AccessibleValue associated with this object. In the 0N/A * implementation of the Java Accessibility API for this class, 0N/A * return this object, which is responsible for implementing the 0N/A * AccessibleValue interface on behalf of itself. 0N/A * @return this object 0N/A * Returns the number of Actions available in this object. The 0N/A * default behavior of a button is to have one action - toggle 0N/A * @return 1, the number of Actions in this object 0N/A * Return a description of the specified action of the object. 0N/A * @param i zero-based index of the actions 0N/A * Perform the specified Action on the object 0N/A * @param i zero-based index of actions 0N/A * @return true if the the action was performed; else false. 0N/A * Get the value of this object as a Number. 0N/A * @return An Integer of 0 if this isn't selected or an Integer of 1 if 0N/A * @see AbstractButton#isSelected 0N/A * Set the value of this object as a Number. 0N/A * @return True if the value was set. 0N/A * Get the minimum value of this object as a Number. 0N/A * @return an Integer of 0. 0N/A * Get the maximum value of this object as a Number. 0N/A * @return An Integer of 1. 0N/A /* AccessibleText ---------- */ 0N/A * Given a point in local coordinates, return the zero-based index 0N/A * of the character under that Point. If the point is invalid, 0N/A * this method returns -1. 0N/A * Note: the AbstractButton must have a valid size (e.g. have 0N/A * been added to a parent container whose ancestor container 0N/A * is a valid top-level window) for this method to be able 0N/A * to return a meaningful value. 0N/A * @param p the Point in local coordinates 0N/A * @return the zero-based index of the character under Point p; if 0N/A * Point is invalid returns -1. 0N/A * Determine the bounding box of the character at the given 0N/A * index into the string. The bounds are returned in local 0N/A * coordinates. If the index is invalid an empty rectangle is 0N/A * Note: the AbstractButton must have a valid size (e.g. have 0N/A * been added to a parent container whose ancestor container 0N/A * is a valid top-level window) for this method to be able 0N/A * to return a meaningful value. 0N/A * @param i the index into the String 0N/A * @return the screen coordinates of the character's the bounding box, 0N/A * if index is invalid returns an empty rectangle. 0N/A * Return the number of characters (valid indicies) 0N/A * @return the number of characters 0N/A * Return the zero-based offset of the caret. 0N/A * Note: That to the right of the caret will have the same index 0N/A * value as the offset (the caret is between two characters). 0N/A * @return the zero-based offset of the caret. 0N/A // There is no caret. 0N/A * Returns the String at a given index. 0N/A * @param part the AccessibleText.CHARACTER, AccessibleText.WORD, 0N/A * or AccessibleText.SENTENCE to retrieve 0N/A * @param index an index within the text >= 0 0N/A * @return the letter, word, or sentence, 0N/A * null for an invalid index or part 0N/A * Returns the String after a given index. 0N/A * @param part the AccessibleText.CHARACTER, AccessibleText.WORD, 0N/A * or AccessibleText.SENTENCE to retrieve 0N/A * @param index an index within the text >= 0 0N/A * @return the letter, word, or sentence, null for an invalid 0N/A * Returns the String before a given index. 0N/A * @param part the AccessibleText.CHARACTER, AccessibleText.WORD, 0N/A * or AccessibleText.SENTENCE to retrieve 0N/A * @param index an index within the text >= 0 0N/A * @return the letter, word, or sentence, null for an invalid index 0N/A * Return the AttributeSet for a given character at a given index 0N/A * @param i the zero-based index into the text 0N/A * @return the AttributeSet of the character 0N/A * Returns the start offset within the selected text. 0N/A * If there is no selection, but there is 0N/A * a caret, the start and end offsets will be the same. 0N/A * @return the index into the text of the start of the selection 0N/A // Text cannot be selected. 0N/A * Returns the end offset within the selected text. 0N/A * If there is no selection, but there is 0N/A * a caret, the start and end offsets will be the same. 0N/A * @return the index into teh text of the end of the selection 0N/A // Text cannot be selected. 0N/A * Returns the portion of the text that is selected. 0N/A * @return the String portion of the text that is selected 0N/A // Text cannot be selected. 0N/A * Returns the text substring starting at the specified 0N/A * offset with the specified length. 0N/A * Returns the bounding rectangle for the component text. 0N/A // ----- AccessibleExtendedComponent 0N/A * Returns the AccessibleExtendedComponent 0N/A * @return the AccessibleExtendedComponent 0N/A * Returns the tool tip text 0N/A * @return the tool tip text, if supported, of the object; 0N/A * Returns the titled border text 0N/A * @return the titled border text, if supported, of the object; 0N/A * Returns key bindings associated with this object 0N/A * @return the key bindings, if supported, of the object; 0N/A * @see AccessibleKeyBinding 0N/A * Returns the number of key bindings for this object 0N/A * @return the zero-based number of key bindings for this object 0N/A * Returns a key binding for this object. The value returned is an 0N/A * java.lang.Object which must be cast to appropriate type depending 0N/A * on the underlying implementation of the key. For example, if the 0N/A * Object returned is a javax.swing.KeyStroke, the user of this 0N/A * method should do the following: 0N/A * Component c = <get the component that has the key bindings> 0N/A * AccessibleContext ac = c.getAccessibleContext(); 0N/A * AccessibleKeyBinding akb = ac.getAccessibleKeyBinding(); 0N/A * for (int i = 0; i < akb.getAccessibleKeyBindingCount(); i++) { 0N/A * Object o = akb.getAccessibleKeyBinding(i); 0N/A * if (o instanceof javax.swing.KeyStroke) { 0N/A * javax.swing.KeyStroke keyStroke = (javax.swing.KeyStroke)o; 0N/A * <do something with the key binding> 0N/A * @param i zero-based index of the key bindings 0N/A * @return a javax.lang.Object which specifies the key binding 0N/A * @exception IllegalArgumentException if the index is 0N/A * @see #getAccessibleKeyBindingCount