diff options
author | Anthony Balkissoon <abalkiss@redhat.com> | 2005-07-12 20:19:07 +0000 |
---|---|---|
committer | Anthony Balkissoon <abalkiss@redhat.com> | 2005-07-12 20:19:07 +0000 |
commit | 1e62468233ce2fab4926e1bad5e459f6d272aaae (patch) | |
tree | 105c6bb3abb621977af848ee0c392d0509f01398 | |
parent | ccf73d8ebc22b36f719bfb998e0d64e99029417a (diff) | |
download | classpath-1e62468233ce2fab4926e1bad5e459f6d272aaae.tar.gz |
2005-07-12 Anthony Balkissoon <abalkiss@redhat.com>
* javax/swing/DefaultButtonModel.java:
(changeState): If the button is a JToggleButton fire action events
when it changes between (selected/unselected) not when it changes
from pressed to unpressed. Fire action events after firing
ItemStateChanged events.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | javax/swing/DefaultButtonModel.java | 15 |
2 files changed, 22 insertions, 1 deletions
@@ -1,3 +1,11 @@ +2005-07-12 Anthony Balkissoon <abalkiss@redhat.com> + + * javax/swing/DefaultButtonModel.java: + (changeState): If the button is a JToggleButton fire action events + when it changes between (selected/unselected) not when it changes + from pressed to unpressed. Fire action events after firing + ItemStateChanged events. + 2005-07-12 Aaron Luchko <aluchko@redhat.com> * gnu/classpath/jdwp/processor/PacketProcessor.java (run): Send diff --git a/javax/swing/DefaultButtonModel.java b/javax/swing/DefaultButtonModel.java index 0c51970a3..cd72afcc0 100644 --- a/javax/swing/DefaultButtonModel.java +++ b/javax/swing/DefaultButtonModel.java @@ -318,6 +318,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable { int oldstate = stateMask; int newstate; + boolean toggle = (this instanceof JToggleButton.ToggleButtonModel); if (b) newstate = oldstate | stateflag; @@ -339,6 +340,12 @@ public class DefaultButtonModel implements ButtonModel, Serializable { fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, null, ItemEvent.SELECTED)); + // If the button is a toggle button then we fire action performed when + // the button changes state (selected/deselected), not when it changes + // from pressed to unpressed + if (toggle) + fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, + actionCommand)); if (group != null) group.setSelected(this, true); } @@ -347,12 +354,18 @@ public class DefaultButtonModel implements ButtonModel, Serializable { fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, null, ItemEvent.DESELECTED)); + // If the button is a toggle button then we fire action performed when + // the button changes state (selected/deselected), not when it changes + // from pressed to unpressed + if (toggle) + fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, + actionCommand)); if (group != null) group.setSelected(this, false); } else if (((oldstate & ARMED) == ARMED && (oldstate & PRESSED) == PRESSED) - && ((newstate & ARMED) == ARMED && (newstate & PRESSED) == 0)) + && ((newstate & ARMED) == ARMED && (newstate & PRESSED) == 0) && (!toggle)) fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, actionCommand)); } |