From 21ab449df7e458702de8e8c6a96fd912b26faf5c Mon Sep 17 00:00:00 2001 From: Robert Schuster Date: Wed, 13 Jul 2005 22:47:54 +0000 Subject: 2005-07-14 Robert Schuster * javax/swing/AbstractButton.java: Minor doc fixes. (getActionCommand): Access field directly. (setActionCommand): Dito. (fireActionPerformed): Copy ActionEvent instance instead of reusing it. --- ChangeLog | 8 ++++++++ javax/swing/AbstractButton.java | 24 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a84f74ea..2763e11f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-07-14 Robert Schuster + + * javax/swing/AbstractButton.java: Minor doc fixes. + (getActionCommand): Access field directly. + (setActionCommand): Dito. + (fireActionPerformed): Copy ActionEvent instance instead + of reusing it. + 2005-07-13 Roman Kennke * javax/swing/BoundedRangeModel.java: diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java index 6575f939a..abafb164f 100644 --- a/javax/swing/AbstractButton.java +++ b/javax/swing/AbstractButton.java @@ -600,27 +600,27 @@ public abstract class AbstractButton extends JComponent /** *

Returns the action command string for this button's model.

* - *

If the action command string is null, the button's + *

If the action command was set to null, the button's * text (label) is returned instead.

* * @return The current action command string from the button's model */ public String getActionCommand() { - String ac = getModel().getActionCommand(); + String ac = model.getActionCommand(); - return (ac != null) ? ac : text; + return (ac != null ? ac : text); } /** * Sets the action command string for this button's model. * - * @param aCommand The new action command string to set in the button's + * @param actionCommand The new action command string to set in the button's * model. */ - public void setActionCommand(String aCommand) + public void setActionCommand(String actionCommand) { - getModel().setActionCommand(aCommand); + model.setActionCommand(actionCommand); } /** @@ -749,11 +749,19 @@ public abstract class AbstractButton extends JComponent */ protected void fireActionPerformed(ActionEvent e) { - e.setSource(this); + // Dispatch a copy of the given ActionEvent in order to + // set the source and action command correctly. + ActionEvent ae = new ActionEvent( + this, + e.getID(), + getActionCommand(), + e.getWhen(), + e.getModifiers()); + ActionListener[] listeners = getActionListeners(); for (int i = 0; i < listeners.length; i++) - listeners[i].actionPerformed(e); + listeners[i].actionPerformed(ae); } /** -- cgit v1.2.1