< prev index next >
src/java.desktop/share/classes/javax/swing/AbstractButton.java
Print this page
*** 47,59 ****
/**
* Defines common behaviors for buttons and menu items.
* <p>
* Buttons can be configured, and to some degree controlled, by
* <code><a href="Action.html">Action</a></code>s. Using an
! * <code>Action</code> with a button has many benefits beyond directly
* configuring a button. Refer to <a href="Action.html#buttonActions">
! * Swing Components Supporting <code>Action</code></a> for more
* details, and you can find more information in <a
* href="http://docs.oracle.com/javase/tutorial/uiswing/misc/action.html">How
* to Use Actions</a>, a section in <em>The Java Tutorial</em>.
* <p>
* For further information see
--- 47,59 ----
/**
* Defines common behaviors for buttons and menu items.
* <p>
* Buttons can be configured, and to some degree controlled, by
* <code><a href="Action.html">Action</a></code>s. Using an
! * {@code Action} with a button has many benefits beyond directly
* configuring a button. Refer to <a href="Action.html#buttonActions">
! * Swing Components Supporting {@code Action}</a> for more
* details, and you can find more information in <a
* href="http://docs.oracle.com/javase/tutorial/uiswing/misc/action.html">How
* to Use Actions</a>, a section in <em>The Java Tutorial</em>.
* <p>
* For further information see
*** 65,75 ****
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Jeff Dinkins
* @since 1.2
*/
--- 65,75 ----
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Jeff Dinkins
* @since 1.2
*/
*** 214,263 ****
* Combined listeners: ActionListener, ChangeListener, ItemListener.
*/
private Handler handler;
/**
! * The button model's <code>changeListener</code>.
*/
protected ChangeListener changeListener = null;
/**
! * The button model's <code>ActionListener</code>.
*/
protected ActionListener actionListener = null;
/**
! * The button model's <code>ItemListener</code>.
*/
protected ItemListener itemListener = null;
/**
! * Only one <code>ChangeEvent</code> is needed per button
* instance since the
* event's only state is the source property. The source of events
* generated is always "this".
*/
protected transient ChangeEvent changeEvent;
private boolean hideActionText = false;
/**
! * Sets the <code>hideActionText</code> property, which determines
! * whether the button displays text from the <code>Action</code>.
! * This is useful only if an <code>Action</code> has been
* installed on the button.
*
! * @param hideActionText <code>true</code> if the button's
! * <code>text</code> property should not reflect
! * that of the <code>Action</code>; the default is
! * <code>false</code>
* @see <a href="Action.html#buttonActions">Swing Components Supporting
* <code>Action</code></a>
* @since 1.6
* @beaninfo
* bound: true
* expert: true
* description: Whether the text of the button should come from
! * the <code>Action</code>.
*/
public void setHideActionText(boolean hideActionText) {
if (hideActionText != this.hideActionText) {
this.hideActionText = hideActionText;
if (getAction() != null) {
--- 214,263 ----
* Combined listeners: ActionListener, ChangeListener, ItemListener.
*/
private Handler handler;
/**
! * The button model's {@code changeListener}.
*/
protected ChangeListener changeListener = null;
/**
! * The button model's {@code ActionListener}.
*/
protected ActionListener actionListener = null;
/**
! * The button model's {@code ItemListener}.
*/
protected ItemListener itemListener = null;
/**
! * Only one {@code ChangeEvent} is needed per button
* instance since the
* event's only state is the source property. The source of events
* generated is always "this".
*/
protected transient ChangeEvent changeEvent;
private boolean hideActionText = false;
/**
! * Sets the {@code hideActionText} property, which determines
! * whether the button displays text from the {@code Action}.
! * This is useful only if an {@code Action} has been
* installed on the button.
*
! * @param hideActionText {@code true} if the button's
! * {@code text} property should not reflect
! * that of the {@code Action}; the default is
! * {@code false}
* @see <a href="Action.html#buttonActions">Swing Components Supporting
* <code>Action</code></a>
* @since 1.6
* @beaninfo
* bound: true
* expert: true
* description: Whether the text of the button should come from
! * the {@code Action}.
*/
public void setHideActionText(boolean hideActionText) {
if (hideActionText != this.hideActionText) {
this.hideActionText = hideActionText;
if (getAction() != null) {
*** 267,284 ****
hideActionText);
}
}
/**
! * Returns the value of the <code>hideActionText</code> property, which
* determines whether the button displays text from the
! * <code>Action</code>. This is useful only if an <code>Action</code>
* has been installed on the button.
*
! * @return <code>true</code> if the button's <code>text</code>
* property should not reflect that of the
! * <code>Action</code>; the default is <code>false</code>
* @since 1.6
*/
public boolean getHideActionText() {
return hideActionText;
}
--- 267,284 ----
hideActionText);
}
}
/**
! * Returns the value of the {@code hideActionText} property, which
* determines whether the button displays text from the
! * {@code Action}. This is useful only if an {@code Action}
* has been installed on the button.
*
! * @return {@code true} if the button's {@code text}
* property should not reflect that of the
! * {@code Action}; the default is {@code false}
* @since 1.6
*/
public boolean getHideActionText() {
return hideActionText;
}
*** 329,340 ****
return model.isSelected();
}
/**
* Sets the state of the button. Note that this method does not
! * trigger an <code>actionEvent</code>.
! * Call <code>doClick</code> to perform a programmatic action change.
*
* @param b true if the button is selected, otherwise false
*/
public void setSelected(boolean b) {
boolean oldValue = isSelected();
--- 329,340 ----
return model.isSelected();
}
/**
* Sets the state of the button. Note that this method does not
! * trigger an {@code actionEvent}.
! * Call {@code doClick} to perform a programmatic action change.
*
* @param b true if the button is selected, otherwise false
*/
public void setSelected(boolean b) {
boolean oldValue = isSelected();
*** 359,369 ****
}
/**
* Programmatically perform a "click". This does the same
* thing as if the user had pressed and released the button.
! * The button stays visually "pressed" for <code>pressTime</code>
* milliseconds.
*
* @param pressTime the time to "hold down" the button, in milliseconds
*/
public void doClick(int pressTime) {
--- 359,369 ----
}
/**
* Programmatically perform a "click". This does the same
* thing as if the user had pressed and released the button.
! * The button stays visually "pressed" for {@code pressTime}
* milliseconds.
*
* @param pressTime the time to "hold down" the button, in milliseconds
*/
public void doClick(int pressTime) {
*** 379,393 ****
model.setArmed(false);
}
/**
* Sets space for margin between the button's border and
! * the label. Setting to <code>null</code> will cause the button to
! * use the default margin. The button's default <code>Border</code>
* object will use this value to create the proper margin.
* However, if a non-default border is set on the button,
! * it is that <code>Border</code> object's responsibility to create the
* appropriate margin space (else this property will
* effectively be ignored).
*
* @param m the space between the border and the label
*
--- 379,393 ----
model.setArmed(false);
}
/**
* Sets space for margin between the button's border and
! * the label. Setting to {@code null} will cause the button to
! * use the default margin. The button's default {@code Border}
* object will use this value to create the proper margin.
* However, if a non-default border is set on the button,
! * it is that {@code Border} object's responsibility to create the
* appropriate margin space (else this property will
* effectively be ignored).
*
* @param m the space between the border and the label
*
*** 421,441 ****
/**
* Returns the margin between the button's border and
* the label.
*
! * @return an <code>Insets</code> object specifying the margin
* between the botton's border and the label
* @see #setMargin
*/
public Insets getMargin() {
return (margin == null) ? null : (Insets) margin.clone();
}
/**
* Returns the default icon.
! * @return the default <code>Icon</code>
* @see #setIcon
*/
public Icon getIcon() {
return defaultIcon;
}
--- 421,441 ----
/**
* Returns the margin between the button's border and
* the label.
*
! * @return an {@code Insets} object specifying the margin
* between the botton's border and the label
* @see #setMargin
*/
public Insets getMargin() {
return (margin == null) ? null : (Insets) margin.clone();
}
/**
* Returns the default icon.
! * @return the default {@code Icon}
* @see #setIcon
*/
public Icon getIcon() {
return defaultIcon;
}
*** 482,492 ****
}
}
/**
* Returns the pressed icon for the button.
! * @return the <code>pressedIcon</code> property
* @see #setPressedIcon
*/
public Icon getPressedIcon() {
return pressedIcon;
}
--- 482,492 ----
}
}
/**
* Returns the pressed icon for the button.
! * @return the {@code pressedIcon} property
* @see #setPressedIcon
*/
public Icon getPressedIcon() {
return pressedIcon;
}
*** 516,526 ****
}
}
/**
* Returns the selected icon for the button.
! * @return the <code>selectedIcon</code> property
* @see #setSelectedIcon
*/
public Icon getSelectedIcon() {
return selectedIcon;
}
--- 516,526 ----
}
}
/**
* Returns the selected icon for the button.
! * @return the {@code selectedIcon} property
* @see #setSelectedIcon
*/
public Icon getSelectedIcon() {
return selectedIcon;
}
*** 562,572 ****
}
}
/**
* Returns the rollover icon for the button.
! * @return the <code>rolloverIcon</code> property
* @see #setRolloverIcon
*/
public Icon getRolloverIcon() {
return rolloverIcon;
}
--- 562,572 ----
}
}
/**
* Returns the rollover icon for the button.
! * @return the {@code rolloverIcon} property
* @see #setRolloverIcon
*/
public Icon getRolloverIcon() {
return rolloverIcon;
}
*** 598,608 ****
}
/**
* Returns the rollover selection icon for the button.
! * @return the <code>rolloverSelectedIcon</code> property
* @see #setRolloverSelectedIcon
*/
public Icon getRolloverSelectedIcon() {
return rolloverSelectedIcon;
}
--- 598,608 ----
}
/**
* Returns the rollover selection icon for the button.
! * @return the {@code rolloverSelectedIcon} property
* @see #setRolloverSelectedIcon
*/
public Icon getRolloverSelectedIcon() {
return rolloverSelectedIcon;
}
*** 642,652 ****
* the look and feel to construct an appropriate disabled Icon.
* <p>
* Some look and feels might not render the disabled Icon, in which
* case they will ignore this.
*
! * @return the <code>disabledIcon</code> property
* @see #getPressedIcon
* @see #setDisabledIcon
* @see javax.swing.LookAndFeel#getDisabledIcon
*/
@Transient
--- 642,652 ----
* the look and feel to construct an appropriate disabled Icon.
* <p>
* Some look and feels might not render the disabled Icon, in which
* case they will ignore this.
*
! * @return the {@code disabledIcon} property
* @see #getPressedIcon
* @see #setDisabledIcon
* @see javax.swing.LookAndFeel#getDisabledIcon
*/
@Transient
*** 688,703 ****
/**
* Returns the icon used by the button when it's disabled and selected.
* If no disabled selection icon has been set, this will forward
* the call to the LookAndFeel to construct an appropriate disabled
* Icon from the selection icon if it has been set and to
! * <code>getDisabledIcon()</code> otherwise.
* <p>
* Some look and feels might not render the disabled selected Icon, in
* which case they will ignore this.
*
! * @return the <code>disabledSelectedIcon</code> property
* @see #getDisabledIcon
* @see #setDisabledSelectedIcon
* @see javax.swing.LookAndFeel#getDisabledSelectedIcon
*/
public Icon getDisabledSelectedIcon() {
--- 688,703 ----
/**
* Returns the icon used by the button when it's disabled and selected.
* If no disabled selection icon has been set, this will forward
* the call to the LookAndFeel to construct an appropriate disabled
* Icon from the selection icon if it has been set and to
! * {@code getDisabledIcon()} otherwise.
* <p>
* Some look and feels might not render the disabled selected Icon, in
* which case they will ignore this.
*
! * @return the {@code disabledSelectedIcon} property
* @see #getDisabledIcon
* @see #setDisabledSelectedIcon
* @see javax.swing.LookAndFeel#getDisabledSelectedIcon
*/
public Icon getDisabledSelectedIcon() {
*** 744,754 ****
}
/**
* Returns the vertical alignment of the text and icon.
*
! * @return the <code>verticalAlignment</code> property, one of the
* following values:
* <ul>
* <li>{@code SwingConstants.CENTER} (the default)
* <li>{@code SwingConstants.TOP}
* <li>{@code SwingConstants.BOTTOM}
--- 744,754 ----
}
/**
* Returns the vertical alignment of the text and icon.
*
! * @return the {@code verticalAlignment} property, one of the
* following values:
* <ul>
* <li>{@code SwingConstants.CENTER} (the default)
* <li>{@code SwingConstants.TOP}
* <li>{@code SwingConstants.BOTTOM}
*** 786,796 ****
/**
* Returns the horizontal alignment of the icon and text.
* {@code AbstractButton}'s default is {@code SwingConstants.CENTER},
* but subclasses such as {@code JCheckBox} may use a different default.
*
! * @return the <code>horizontalAlignment</code> property,
* one of the following values:
* <ul>
* <li>{@code SwingConstants.RIGHT}
* <li>{@code SwingConstants.LEFT}
* <li>{@code SwingConstants.CENTER}
--- 786,796 ----
/**
* Returns the horizontal alignment of the icon and text.
* {@code AbstractButton}'s default is {@code SwingConstants.CENTER},
* but subclasses such as {@code JCheckBox} may use a different default.
*
! * @return the {@code horizontalAlignment} property,
* one of the following values:
* <ul>
* <li>{@code SwingConstants.RIGHT}
* <li>{@code SwingConstants.LEFT}
* <li>{@code SwingConstants.CENTER}
*** 838,848 ****
}
/**
* Returns the vertical position of the text relative to the icon.
! * @return the <code>verticalTextPosition</code> property,
* one of the following values:
* <ul>
* <li>{@code SwingConstants.CENTER} (the default)
* <li>{@code SwingConstants.TOP}
* <li>{@code SwingConstants.BOTTOM}
--- 838,848 ----
}
/**
* Returns the vertical position of the text relative to the icon.
! * @return the {@code verticalTextPosition} property,
* one of the following values:
* <ul>
* <li>{@code SwingConstants.CENTER} (the default)
* <li>{@code SwingConstants.TOP}
* <li>{@code SwingConstants.BOTTOM}
*** 877,887 ****
repaint();
}
/**
* Returns the horizontal position of the text relative to the icon.
! * @return the <code>horizontalTextPosition</code> property,
* one of the following values:
* <ul>
* <li>{@code SwingConstants.RIGHT}
* <li>{@code SwingConstants.LEFT}
* <li>{@code SwingConstants.CENTER}
--- 877,887 ----
repaint();
}
/**
* Returns the horizontal position of the text relative to the icon.
! * @return the {@code horizontalTextPosition} property,
* one of the following values:
* <ul>
* <li>{@code SwingConstants.RIGHT}
* <li>{@code SwingConstants.LEFT}
* <li>{@code SwingConstants.CENTER}
*** 901,911 ****
* <li>{@code SwingConstants.LEFT}
* <li>{@code SwingConstants.CENTER}
* <li>{@code SwingConstants.LEADING}
* <li>{@code SwingConstants.TRAILING} (the default)
* </ul>
! * @exception IllegalArgumentException if <code>textPosition</code>
* is not one of the legal values listed above
* @beaninfo
* bound: true
* enum: LEFT SwingConstants.LEFT
* CENTER SwingConstants.CENTER
--- 901,911 ----
* <li>{@code SwingConstants.LEFT}
* <li>{@code SwingConstants.CENTER}
* <li>{@code SwingConstants.LEADING}
* <li>{@code SwingConstants.TRAILING} (the default)
* </ul>
! * @exception IllegalArgumentException if {@code textPosition}
* is not one of the legal values listed above
* @beaninfo
* bound: true
* enum: LEFT SwingConstants.LEFT
* CENTER SwingConstants.CENTER
*** 1061,1096 ****
private Action action;
private PropertyChangeListener actionPropertyChangeListener;
/**
! * Sets the <code>Action</code>.
! * The new <code>Action</code> replaces any previously set
! * <code>Action</code> but does not affect <code>ActionListeners</code>
! * independently added with <code>addActionListener</code>.
! * If the <code>Action</code> is already a registered
! * <code>ActionListener</code> for the button, it is not re-registered.
* <p>
! * Setting the <code>Action</code> results in immediately changing
* all the properties described in <a href="Action.html#buttonActions">
! * Swing Components Supporting <code>Action</code></a>.
* Subsequently, the button's properties are automatically updated
! * as the <code>Action</code>'s properties change.
* <p>
* This method uses three other methods to set
! * and help track the <code>Action</code>'s property values.
! * It uses the <code>configurePropertiesFromAction</code> method
* to immediately change the button's properties.
! * To track changes in the <code>Action</code>'s property values,
! * this method registers the <code>PropertyChangeListener</code>
! * returned by <code>createActionPropertyChangeListener</code>. The
* default {@code PropertyChangeListener} invokes the
* {@code actionPropertyChanged} method when a property in the
* {@code Action} changes.
*
! * @param a the <code>Action</code> for the <code>AbstractButton</code>,
! * or <code>null</code>
* @since 1.3
* @see Action
* @see #getAction
* @see #configurePropertiesFromAction
* @see #createActionPropertyChangeListener
--- 1061,1096 ----
private Action action;
private PropertyChangeListener actionPropertyChangeListener;
/**
! * Sets the {@code Action}.
! * The new {@code Action} replaces any previously set
! * {@code Action} but does not affect {@code ActionListeners}
! * independently added with {@code addActionListener}.
! * If the {@code Action} is already a registered
! * {@code ActionListener} for the button, it is not re-registered.
* <p>
! * Setting the {@code Action} results in immediately changing
* all the properties described in <a href="Action.html#buttonActions">
! * Swing Components Supporting {@code Action}</a>.
* Subsequently, the button's properties are automatically updated
! * as the {@code Action}'s properties change.
* <p>
* This method uses three other methods to set
! * and help track the {@code Action}'s property values.
! * It uses the {@code configurePropertiesFromAction} method
* to immediately change the button's properties.
! * To track changes in the {@code Action}'s property values,
! * this method registers the {@code PropertyChangeListener}
! * returned by {@code createActionPropertyChangeListener}. The
* default {@code PropertyChangeListener} invokes the
* {@code actionPropertyChanged} method when a property in the
* {@code Action} changes.
*
! * @param a the {@code Action} for the {@code AbstractButton},
! * or {@code null}
* @since 1.3
* @see Action
* @see #getAction
* @see #configurePropertiesFromAction
* @see #createActionPropertyChangeListener
*** 1133,1164 ****
}
return isListener;
}
/**
! * Returns the currently set <code>Action</code> for this
! * <code>ActionEvent</code> source, or <code>null</code>
! * if no <code>Action</code> is set.
*
! * @return the <code>Action</code> for this <code>ActionEvent</code>
! * source, or <code>null</code>
* @since 1.3
* @see Action
* @see #setAction
*/
public Action getAction() {
return action;
}
/**
* Sets the properties on this button to match those in the specified
! * <code>Action</code>. Refer to <a href="Action.html#buttonActions">
! * Swing Components Supporting <code>Action</code></a> for more
* details as to which properties this sets.
*
! * @param a the <code>Action</code> from which to get the properties,
! * or <code>null</code>
* @since 1.3
* @see Action
* @see #setAction
*/
protected void configurePropertiesFromAction(Action a) {
--- 1133,1164 ----
}
return isListener;
}
/**
! * Returns the currently set {@code Action} for this
! * {@code ActionEvent} source, or {@code null}
! * if no {@code Action} is set.
*
! * @return the {@code Action} for this {@code ActionEvent}
! * source, or {@code null}
* @since 1.3
* @see Action
* @see #setAction
*/
public Action getAction() {
return action;
}
/**
* Sets the properties on this button to match those in the specified
! * {@code Action}. Refer to <a href="Action.html#buttonActions">
! * Swing Components Supporting {@code Action}</a> for more
* details as to which properties this sets.
*
! * @param a the {@code Action} from which to get the properties,
! * or {@code null}
* @since 1.3
* @see Action
* @see #setAction
*/
protected void configurePropertiesFromAction(Action a) {
*** 1203,1216 ****
* need to invoke this. Subclasses that support additional {@code Action}
* properties should override this and
* {@code configurePropertiesFromAction}.
* <p>
* Refer to the table at <a href="Action.html#buttonActions">
! * Swing Components Supporting <code>Action</code></a> for a list of
* the properties this method sets.
*
! * @param action the <code>Action</code> associated with this button
* @param propertyName the name of the property that changed
* @since 1.6
* @see Action
* @see #configurePropertiesFromAction
*/
--- 1203,1216 ----
* need to invoke this. Subclasses that support additional {@code Action}
* properties should override this and
* {@code configurePropertiesFromAction}.
* <p>
* Refer to the table at <a href="Action.html#buttonActions">
! * Swing Components Supporting {@code Action}</a> for a list of
* the properties this method sets.
*
! * @param action the {@code Action} associated with this button
* @param propertyName the name of the property that changed
* @since 1.6
* @see Action
* @see #configurePropertiesFromAction
*/
*** 1328,1344 ****
}
}
}
/**
! * Creates and returns a <code>PropertyChangeListener</code> that is
* responsible for listening for changes from the specified
! * <code>Action</code> and updating the appropriate properties.
* <p>
* <b>Warning:</b> If you subclass this do not create an anonymous
* inner class. If you do the lifetime of the button will be tied to
! * that of the <code>Action</code>.
*
* @param a the button's action
* @return the {@code PropertyChangeListener}
* @since 1.3
* @see Action
--- 1328,1344 ----
}
}
}
/**
! * Creates and returns a {@code PropertyChangeListener} that is
* responsible for listening for changes from the specified
! * {@code Action} and updating the appropriate properties.
* <p>
* <b>Warning:</b> If you subclass this do not create an anonymous
* inner class. If you do the lifetime of the button will be tied to
! * that of the {@code Action}.
*
* @param a the button's action
* @return the {@code PropertyChangeListener}
* @since 1.3
* @see Action
*** 1369,1398 ****
}
}
}
/**
! * Gets the <code>borderPainted</code> property.
*
! * @return the value of the <code>borderPainted</code> property
* @see #setBorderPainted
*/
public boolean isBorderPainted() {
return paintBorder;
}
/**
! * Sets the <code>borderPainted</code> property.
! * If <code>true</code> and the button has a border,
* the border is painted. The default value for the
! * <code>borderPainted</code> property is <code>true</code>.
* <p>
* Some look and feels might not support
! * the <code>borderPainted</code> property,
* in which case they ignore this.
*
! * @param b if true and border property is not <code>null</code>,
* the border is painted
* @see #isBorderPainted
* @beaninfo
* bound: true
* attribute: visualUpdate true
--- 1369,1398 ----
}
}
}
/**
! * Gets the {@code borderPainted} property.
*
! * @return the value of the {@code borderPainted} property
* @see #setBorderPainted
*/
public boolean isBorderPainted() {
return paintBorder;
}
/**
! * Sets the {@code borderPainted} property.
! * If {@code true} and the button has a border,
* the border is painted. The default value for the
! * {@code borderPainted} property is {@code true}.
* <p>
* Some look and feels might not support
! * the {@code borderPainted} property,
* in which case they ignore this.
*
! * @param b if true and border property is not {@code null},
* the border is painted
* @see #isBorderPainted
* @beaninfo
* bound: true
* attribute: visualUpdate true
*** 1408,1420 ****
repaint();
}
}
/**
! * Paint the button's border if <code>BorderPainted</code>
* property is true and the button has a border.
! * @param g the <code>Graphics</code> context in which to paint
*
* @see #paint
* @see #setBorder
*/
protected void paintBorder(Graphics g) {
--- 1408,1420 ----
repaint();
}
}
/**
! * Paint the button's border if {@code BorderPainted}
* property is true and the button has a border.
! * @param g the {@code Graphics} context in which to paint
*
* @see #paint
* @see #setBorder
*/
protected void paintBorder(Graphics g) {
*** 1422,1449 ****
super.paintBorder(g);
}
}
/**
! * Gets the <code>paintFocus</code> property.
*
! * @return the <code>paintFocus</code> property
* @see #setFocusPainted
*/
public boolean isFocusPainted() {
return paintFocus;
}
/**
! * Sets the <code>paintFocus</code> property, which must
! * be <code>true</code> for the focus state to be painted.
! * The default value for the <code>paintFocus</code> property
! * is <code>true</code>.
* Some look and feels might not paint focus state;
* they will ignore this property.
*
! * @param b if <code>true</code>, the focus state should be painted
* @see #isFocusPainted
* @beaninfo
* bound: true
* attribute: visualUpdate true
* description: Whether focus should be painted
--- 1422,1449 ----
super.paintBorder(g);
}
}
/**
! * Gets the {@code paintFocus} property.
*
! * @return the {@code paintFocus} property
* @see #setFocusPainted
*/
public boolean isFocusPainted() {
return paintFocus;
}
/**
! * Sets the {@code paintFocus} property, which must
! * be {@code true} for the focus state to be painted.
! * The default value for the {@code paintFocus} property
! * is {@code true}.
* Some look and feels might not paint focus state;
* they will ignore this property.
*
! * @param b if {@code true}, the focus state should be painted
* @see #isFocusPainted
* @beaninfo
* bound: true
* attribute: visualUpdate true
* description: Whether focus should be painted
*** 1457,1483 ****
repaint();
}
}
/**
! * Gets the <code>contentAreaFilled</code> property.
*
! * @return the <code>contentAreaFilled</code> property
* @see #setContentAreaFilled
*/
public boolean isContentAreaFilled() {
return contentAreaFilled;
}
/**
! * Sets the <code>contentAreaFilled</code> property.
! * If <code>true</code> the button will paint the content
* area. If you wish to have a transparent button, such as
* an icon only button, for example, then you should set
! * this to <code>false</code>. Do not call <code>setOpaque(false)</code>.
! * The default value for the <code>contentAreaFilled</code>
! * property is <code>true</code>.
* <p>
* This function may cause the component's opaque property to change.
* <p>
* The exact behavior of calling this function varies on a
* component-by-component and L&F-by-L&F basis.
--- 1457,1483 ----
repaint();
}
}
/**
! * Gets the {@code contentAreaFilled} property.
*
! * @return the {@code contentAreaFilled} property
* @see #setContentAreaFilled
*/
public boolean isContentAreaFilled() {
return contentAreaFilled;
}
/**
! * Sets the {@code contentAreaFilled} property.
! * If {@code true} the button will paint the content
* area. If you wish to have a transparent button, such as
* an icon only button, for example, then you should set
! * this to {@code false}. Do not call {@code setOpaque(false)}.
! * The default value for the {@code contentAreaFilled}
! * property is {@code true}.
* <p>
* This function may cause the component's opaque property to change.
* <p>
* The exact behavior of calling this function varies on a
* component-by-component and L&F-by-L&F basis.
*** 1501,1528 ****
repaint();
}
}
/**
! * Gets the <code>rolloverEnabled</code> property.
*
! * @return the value of the <code>rolloverEnabled</code> property
* @see #setRolloverEnabled
*/
public boolean isRolloverEnabled() {
return rolloverEnabled;
}
/**
! * Sets the <code>rolloverEnabled</code> property, which
! * must be <code>true</code> for rollover effects to occur.
! * The default value for the <code>rolloverEnabled</code>
! * property is <code>false</code>.
* Some look and feels might not implement rollover effects;
* they will ignore this property.
*
! * @param b if <code>true</code>, rollover effects should be painted
* @see #isRolloverEnabled
* @beaninfo
* bound: true
* attribute: visualUpdate true
* description: Whether rollover effects should be enabled.
--- 1501,1528 ----
repaint();
}
}
/**
! * Gets the {@code rolloverEnabled} property.
*
! * @return the value of the {@code rolloverEnabled} property
* @see #setRolloverEnabled
*/
public boolean isRolloverEnabled() {
return rolloverEnabled;
}
/**
! * Sets the {@code rolloverEnabled} property, which
! * must be {@code true} for rollover effects to occur.
! * The default value for the {@code rolloverEnabled}
! * property is {@code false}.
* Some look and feels might not implement rollover effects;
* they will ignore this property.
*
! * @param b if {@code true}, rollover effects should be painted
* @see #isRolloverEnabled
* @beaninfo
* bound: true
* attribute: visualUpdate true
* description: Whether rollover effects should be enabled.
*** 1551,1565 ****
* mouseless modifier (usually Alt) will activate this button
* if focus is contained somewhere within this button's ancestor
* window.
* <p>
* A mnemonic must correspond to a single key on the keyboard
! * and should be specified using one of the <code>VK_XXX</code>
! * keycodes defined in <code>java.awt.event.KeyEvent</code>.
* These codes and the wider array of codes for international
* keyboards may be obtained through
! * <code>java.awt.event.KeyEvent.getExtendedKeyCodeForChar</code>.
* Mnemonics are case-insensitive, therefore a key event
* with the corresponding keycode would cause the button to be
* activated whether or not the Shift modifier was pressed.
* <p>
* If the character defined by the mnemonic is found within
--- 1551,1565 ----
* mouseless modifier (usually Alt) will activate this button
* if focus is contained somewhere within this button's ancestor
* window.
* <p>
* A mnemonic must correspond to a single key on the keyboard
! * and should be specified using one of the {@code VK_XXX}
! * keycodes defined in {@code java.awt.event.KeyEvent}.
* These codes and the wider array of codes for international
* keyboards may be obtained through
! * {@code java.awt.event.KeyEvent.getExtendedKeyCodeForChar}.
* Mnemonics are case-insensitive, therefore a key event
* with the corresponding keycode would cause the button to be
* activated whether or not the Shift modifier was pressed.
* <p>
* If the character defined by the mnemonic is found within
*** 1580,1590 ****
model.setMnemonic(mnemonic);
updateMnemonicProperties();
}
/**
! * This method is now obsolete, please use <code>setMnemonic(int)</code>
* to set the mnemonic for a button. This method is only designed
* to handle character values which fall between 'a' and 'z' or
* 'A' and 'Z'.
*
* @param mnemonic a char specifying the mnemonic value
--- 1580,1590 ----
model.setMnemonic(mnemonic);
updateMnemonicProperties();
}
/**
! * This method is now obsolete, please use {@code setMnemonic(int)}
* to set the mnemonic for a button. This method is only designed
* to handle character values which fall between 'a' and 'z' or
* 'A' and 'Z'.
*
* @param mnemonic a char specifying the mnemonic value
*** 1612,1627 ****
* mnemonic change (such as the mnemonic itself, the text...).
* You should only ever have to call this if
* you do not wish the default character to be underlined. For example, if
* the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A'
* to be decorated, as 'Save <u>A</u>s', you would have to invoke
! * <code>setDisplayedMnemonicIndex(5)</code> after invoking
! * <code>setMnemonic(KeyEvent.VK_A)</code>.
*
* @since 1.4
* @param index Index into the String to underline
! * @exception IllegalArgumentException will be thrown if <code>index</code>
* is >= length of the text, or < -1
* @see #getDisplayedMnemonicIndex
*
* @beaninfo
* bound: true
--- 1612,1627 ----
* mnemonic change (such as the mnemonic itself, the text...).
* You should only ever have to call this if
* you do not wish the default character to be underlined. For example, if
* the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A'
* to be decorated, as 'Save <u>A</u>s', you would have to invoke
! * {@code setDisplayedMnemonicIndex(5)} after invoking
! * {@code setMnemonic(KeyEvent.VK_A)}.
*
* @since 1.4
* @param index Index into the String to underline
! * @exception IllegalArgumentException will be thrown if {@code index}
* is >= length of the text, or < -1
* @see #getDisplayedMnemonicIndex
*
* @beaninfo
* bound: true
*** 1730,1749 ****
return multiClickThreshhold;
}
/**
* Returns the model that this button represents.
! * @return the <code>model</code> property
* @see #setModel
*/
public ButtonModel getModel() {
return model;
}
/**
* Sets the model that this button represents.
! * @param newModel the new <code>ButtonModel</code>
* @see #getModel
* @beaninfo
* bound: true
* description: Model that the Button uses.
*/
--- 1730,1749 ----
return multiClickThreshhold;
}
/**
* Returns the model that this button represents.
! * @return the {@code model} property
* @see #setModel
*/
public ButtonModel getModel() {
return model;
}
/**
* Sets the model that this button represents.
! * @param newModel the new {@code ButtonModel}
* @see #getModel
* @beaninfo
* bound: true
* description: Model that the Button uses.
*/
*** 1800,1810 ****
}
/**
* Sets the L&F object that renders this component.
! * @param ui the <code>ButtonUI</code> L&F object
* @see #getUI
* @beaninfo
* bound: true
* hidden: true
* attribute: visualUpdate true
--- 1800,1810 ----
}
/**
* Sets the L&F object that renders this component.
! * @param ui the {@code ButtonUI} L&F object
* @see #getUI
* @beaninfo
* bound: true
* hidden: true
* attribute: visualUpdate true
*** 1822,1834 ****
}
/**
* Resets the UI property to a value from the current look
! * and feel. Subtypes of <code>AbstractButton</code>
* should override this to update the UI. For
! * example, <code>JButton</code> might do the following:
* <pre>
* setUI((ButtonUI)UIManager.getUI(
* "ButtonUI", "javax.swing.plaf.basic.BasicButtonUI", this));
* </pre>
*/
--- 1822,1834 ----
}
/**
* Resets the UI property to a value from the current look
! * and feel. Subtypes of {@code AbstractButton}
* should override this to update the UI. For
! * example, {@code JButton} might do the following:
* <pre>
* setUI((ButtonUI)UIManager.getUI(
* "ButtonUI", "javax.swing.plaf.basic.BasicButtonUI", this));
* </pre>
*/
*** 1843,1855 ****
*
* @param comp the component to be added
* @param constraints an object expressing layout constraints
* for this component
* @param index the position in the container's list at which to
! * insert the component, where <code>-1</code>
* means append to the end
! * @exception IllegalArgumentException if <code>index</code> is invalid
* @exception IllegalArgumentException if adding the container's parent
* to itself
* @exception IllegalArgumentException if adding a window to a container
* @since 1.5
*/
--- 1843,1855 ----
*
* @param comp the component to be added
* @param constraints an object expressing layout constraints
* for this component
* @param index the position in the container's list at which to
! * insert the component, where {@code -1}
* means append to the end
! * @exception IllegalArgumentException if {@code index} is invalid
* @exception IllegalArgumentException if adding the container's parent
* to itself
* @exception IllegalArgumentException if adding a window to a container
* @since 1.5
*/
*** 1872,1882 ****
setLayout = true;
super.setLayout(mgr);
}
/**
! * Adds a <code>ChangeListener</code> to the button.
* @param l the listener to be added
*/
public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
}
--- 1872,1882 ----
setLayout = true;
super.setLayout(mgr);
}
/**
! * Adds a {@code ChangeListener} to the button.
* @param l the listener to be added
*/
public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
}
*** 1888,1901 ****
public void removeChangeListener(ChangeListener l) {
listenerList.remove(ChangeListener.class, l);
}
/**
! * Returns an array of all the <code>ChangeListener</code>s added
* to this AbstractButton with addChangeListener().
*
! * @return all of the <code>ChangeListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public ChangeListener[] getChangeListeners() {
return listenerList.getListeners(ChangeListener.class);
--- 1888,1901 ----
public void removeChangeListener(ChangeListener l) {
listenerList.remove(ChangeListener.class, l);
}
/**
! * Returns an array of all the {@code ChangeListener}s added
* to this AbstractButton with addChangeListener().
*
! * @return all of the {@code ChangeListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public ChangeListener[] getChangeListeners() {
return listenerList.getListeners(ChangeListener.class);
*** 1921,1942 ****
}
}
}
/**
! * Adds an <code>ActionListener</code> to the button.
! * @param l the <code>ActionListener</code> to be added
*/
public void addActionListener(ActionListener l) {
listenerList.add(ActionListener.class, l);
}
/**
! * Removes an <code>ActionListener</code> from the button.
! * If the listener is the currently set <code>Action</code>
! * for the button, then the <code>Action</code>
! * is set to <code>null</code>.
*
* @param l the listener to be removed
*/
public void removeActionListener(ActionListener l) {
if ((l != null) && (getAction() == l)) {
--- 1921,1942 ----
}
}
}
/**
! * Adds an {@code ActionListener} to the button.
! * @param l the {@code ActionListener} to be added
*/
public void addActionListener(ActionListener l) {
listenerList.add(ActionListener.class, l);
}
/**
! * Removes an {@code ActionListener} from the button.
! * If the listener is the currently set {@code Action}
! * for the button, then the {@code Action}
! * is set to {@code null}.
*
* @param l the listener to be removed
*/
public void removeActionListener(ActionListener l) {
if ((l != null) && (getAction() == l)) {
*** 1945,1986 ****
listenerList.remove(ActionListener.class, l);
}
}
/**
! * Returns an array of all the <code>ActionListener</code>s added
* to this AbstractButton with addActionListener().
*
! * @return all of the <code>ActionListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public ActionListener[] getActionListeners() {
return listenerList.getListeners(ActionListener.class);
}
/**
! * Subclasses that want to handle <code>ChangeEvents</code> differently
! * can override this to return another <code>ChangeListener</code>
* implementation.
*
! * @return the new <code>ChangeListener</code>
*/
protected ChangeListener createChangeListener() {
return getHandler();
}
/**
! * Extends <code>ChangeListener</code> to be serializable.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*/
@SuppressWarnings("serial")
protected class ButtonChangeListener implements ChangeListener, Serializable {
// NOTE: This class is NOT used, instead the functionality has
--- 1945,1986 ----
listenerList.remove(ActionListener.class, l);
}
}
/**
! * Returns an array of all the {@code ActionListener}s added
* to this AbstractButton with addActionListener().
*
! * @return all of the {@code ActionListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public ActionListener[] getActionListeners() {
return listenerList.getListeners(ActionListener.class);
}
/**
! * Subclasses that want to handle {@code ChangeEvents} differently
! * can override this to return another {@code ChangeListener}
* implementation.
*
! * @return the new {@code ChangeListener}
*/
protected ChangeListener createChangeListener() {
return getHandler();
}
/**
! * Extends {@code ChangeListener} to be serializable.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*/
@SuppressWarnings("serial")
protected class ButtonChangeListener implements ChangeListener, Serializable {
// NOTE: This class is NOT used, instead the functionality has
*** 1995,2008 ****
/**
* Notifies all listeners that have registered interest for
* notification on this event type. The event instance
! * is lazily created using the <code>event</code>
* parameter.
*
! * @param event the <code>ActionEvent</code> object
* @see EventListenerList
*/
protected void fireActionPerformed(ActionEvent event) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
--- 1995,2008 ----
/**
* Notifies all listeners that have registered interest for
* notification on this event type. The event instance
! * is lazily created using the {@code event}
* parameter.
*
! * @param event the {@code ActionEvent} object
* @see EventListenerList
*/
protected void fireActionPerformed(ActionEvent event) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
*** 2029,2041 ****
}
/**
* Notifies all listeners that have registered interest for
* notification on this event type. The event instance
! * is lazily created using the <code>event</code> parameter.
*
! * @param event the <code>ItemEvent</code> object
* @see EventListenerList
*/
protected void fireItemStateChanged(ItemEvent event) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
--- 2029,2041 ----
}
/**
* Notifies all listeners that have registered interest for
* notification on this event type. The event instance
! * is lazily created using the {@code event} parameter.
*
! * @param event the {@code ItemEvent} object
* @see EventListenerList
*/
protected void fireItemStateChanged(ItemEvent event) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
*** 2107,2172 ****
// *** Deprecated java.awt.Button APIs below *** //
/**
* Returns the label text.
*
! * @return a <code>String</code> containing the label
! * @deprecated - Replaced by <code>getText</code>
*/
@Deprecated
public String getLabel() {
return getText();
}
/**
* Sets the label text.
*
! * @param label a <code>String</code> containing the text
! * @deprecated - Replaced by <code>setText(text)</code>
* @beaninfo
* bound: true
* description: Replace by setText(text)
*/
@Deprecated
public void setLabel(String label) {
setText(label);
}
/**
! * Adds an <code>ItemListener</code> to the <code>checkbox</code>.
! * @param l the <code>ItemListener</code> to be added
*/
public void addItemListener(ItemListener l) {
listenerList.add(ItemListener.class, l);
}
/**
! * Removes an <code>ItemListener</code> from the button.
! * @param l the <code>ItemListener</code> to be removed
*/
public void removeItemListener(ItemListener l) {
listenerList.remove(ItemListener.class, l);
}
/**
! * Returns an array of all the <code>ItemListener</code>s added
* to this AbstractButton with addItemListener().
*
! * @return all of the <code>ItemListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public ItemListener[] getItemListeners() {
return listenerList.getListeners(ItemListener.class);
}
/**
* Returns an array (length 1) containing the label or
! * <code>null</code> if the button is not selected.
*
* @return an array containing 1 Object: the text of the button,
! * if the item is selected; otherwise <code>null</code>
*/
public Object[] getSelectedObjects() {
if (isSelected() == false) {
return null;
}
--- 2107,2172 ----
// *** Deprecated java.awt.Button APIs below *** //
/**
* Returns the label text.
*
! * @return a {@code String} containing the label
! * @deprecated - Replaced by {@code getText}
*/
@Deprecated
public String getLabel() {
return getText();
}
/**
* Sets the label text.
*
! * @param label a {@code String} containing the text
! * @deprecated - Replaced by {@code setText(text)}
* @beaninfo
* bound: true
* description: Replace by setText(text)
*/
@Deprecated
public void setLabel(String label) {
setText(label);
}
/**
! * Adds an {@code ItemListener} to the {@code checkbox}.
! * @param l the {@code ItemListener} to be added
*/
public void addItemListener(ItemListener l) {
listenerList.add(ItemListener.class, l);
}
/**
! * Removes an {@code ItemListener} from the button.
! * @param l the {@code ItemListener} to be removed
*/
public void removeItemListener(ItemListener l) {
listenerList.remove(ItemListener.class, l);
}
/**
! * Returns an array of all the {@code ItemListener}s added
* to this AbstractButton with addItemListener().
*
! * @return all of the {@code ItemListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public ItemListener[] getItemListeners() {
return listenerList.getListeners(ItemListener.class);
}
/**
* Returns an array (length 1) containing the label or
! * {@code null} if the button is not selected.
*
* @return an array containing 1 Object: the text of the button,
! * if the item is selected; otherwise {@code null}
*/
public Object[] getSelectedObjects() {
if (isSelected() == false) {
return null;
}
*** 2197,2211 ****
setAlignmentY(CENTER_ALIGNMENT);
}
/**
! * This is overridden to return false if the current <code>Icon</code>'s
! * <code>Image</code> is not equal to the
! * passed in <code>Image</code> <code>img</code>.
*
! * @param img the <code>Image</code> to be compared
* @param infoflags flags used to repaint the button when the image
* is updated and which determine how much is to be painted
* @param x the x coordinate
* @param y the y coordinate
* @param w the width
--- 2197,2211 ----
setAlignmentY(CENTER_ALIGNMENT);
}
/**
! * This is overridden to return false if the current {@code Icon}'s
! * {@code Image} is not equal to the
! * passed in {@code Image img}.
*
! * @param img the {@code Image} to be compared
* @param infoflags flags used to repaint the button when the image
* is updated and which determine how much is to be painted
* @param x the x coordinate
* @param y the y coordinate
* @param w the width
*** 2273,2293 ****
super.setUIProperty(propertyName, value);
}
}
/**
! * Returns a string representation of this <code>AbstractButton</code>.
* This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
! * be <code>null</code>.
* <P>
! * Overriding <code>paramString</code> to provide information about the
* specific new aspects of the JFC components.
*
! * @return a string representation of this <code>AbstractButton</code>
*/
protected String paramString() {
String defaultIconString = ((defaultIcon != null)
&& (defaultIcon != this) ?
defaultIcon.toString() : "");
--- 2273,2293 ----
super.setUIProperty(propertyName, value);
}
}
/**
! * Returns a string representation of this {@code AbstractButton}.
* This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
! * be {@code null}.
* <P>
! * Overriding {@code paramString} to provide information about the
* specific new aspects of the JFC components.
*
! * @return a string representation of this {@code AbstractButton}
*/
protected String paramString() {
String defaultIconString = ((defaultIcon != null)
&& (defaultIcon != this) ?
defaultIcon.toString() : "");
*** 2388,2408 ****
///////////////////
// Accessibility support
///////////////////
/**
* This class implements accessibility support for the
! * <code>AbstractButton</code> class. It provides an implementation of the
* Java Accessibility API appropriate to button and menu item
* user-interface elements.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
* @since 1.4
*/
@SuppressWarnings("serial") // Same-version serialization only
protected abstract class AccessibleAbstractButton
--- 2388,2408 ----
///////////////////
// Accessibility support
///////////////////
/**
* This class implements accessibility support for the
! * {@code AbstractButton} class. It provides an implementation of the
* Java Accessibility API appropriate to button and menu item
* user-interface elements.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
* @since 1.4
*/
@SuppressWarnings("serial") // Same-version serialization only
protected abstract class AccessibleAbstractButton
*** 2411,2421 ****
/**
* Returns the accessible name of this object.
*
* @return the localized name of the object -- can be
! * <code>null</code> if this
* object does not have a name
*/
public String getAccessibleName() {
String name = accessibleName;
--- 2411,2421 ----
/**
* Returns the accessible name of this object.
*
* @return the localized name of the object -- can be
! * {@code null} if this
* object does not have a name
*/
public String getAccessibleName() {
String name = accessibleName;
*** 3095,3116 ****
* Returns a key binding for this object. The value returned is an
* java.lang.Object which must be cast to appropriate type depending
* on the underlying implementation of the key. For example, if the
* Object returned is a javax.swing.KeyStroke, the user of this
* method should do the following:
! * <nf><code>
* Component c = <get the component that has the key bindings>
* AccessibleContext ac = c.getAccessibleContext();
* AccessibleKeyBinding akb = ac.getAccessibleKeyBinding();
* for (int i = 0; i < akb.getAccessibleKeyBindingCount(); i++) {
* Object o = akb.getAccessibleKeyBinding(i);
* if (o instanceof javax.swing.KeyStroke) {
* javax.swing.KeyStroke keyStroke = (javax.swing.KeyStroke)o;
* <do something with the key binding>
* }
* }
! * </code></nf>
*
* @param i zero-based index of the key bindings
* @return a javax.lang.Object which specifies the key binding
* @exception IllegalArgumentException if the index is
* out of bounds
--- 3095,3116 ----
* Returns a key binding for this object. The value returned is an
* java.lang.Object which must be cast to appropriate type depending
* on the underlying implementation of the key. For example, if the
* Object returned is a javax.swing.KeyStroke, the user of this
* method should do the following:
! * <pre>{@code
* Component c = <get the component that has the key bindings>
* AccessibleContext ac = c.getAccessibleContext();
* AccessibleKeyBinding akb = ac.getAccessibleKeyBinding();
* for (int i = 0; i < akb.getAccessibleKeyBindingCount(); i++) {
* Object o = akb.getAccessibleKeyBinding(i);
* if (o instanceof javax.swing.KeyStroke) {
* javax.swing.KeyStroke keyStroke = (javax.swing.KeyStroke)o;
* <do something with the key binding>
* }
* }
! * }</pre>
*
* @param i zero-based index of the key bindings
* @return a javax.lang.Object which specifies the key binding
* @exception IllegalArgumentException if the index is
* out of bounds
< prev index next >