This patch fixes the problem discussed in the additional comments to bug 13683:
======additional comment #1========== I have discovered another bug in this testcase. If you open a menu, you can see in the taskbar that a new window with the name "." has been opened. And also, on the sun vm if you click on the checkbox you have this output in the console: JMenu is set to off but with classpath you get: JMenu is set to on Perhaps classpath first triggers a actionPerformed ActionEvent and only afterwards changes the selection of the checkbox? ======additional comment #2========== Indeed. I think something is wrong with our JCheckBox. ===================================== For classes whose ButtonModel is a JToggleButton.ToggleButtonModel we fire action events after toggling the state of the button, not when the button becomes unpressed. Patch is attached. 2005-07-12 Anthony Balkissoon <[EMAIL PROTECTED]> * 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.
Index: javax/swing/DefaultButtonModel.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/DefaultButtonModel.java,v retrieving revision 1.20 diff -u -r1.20 DefaultButtonModel.java --- javax/swing/DefaultButtonModel.java 2 Jul 2005 20:32:46 -0000 1.20 +++ javax/swing/DefaultButtonModel.java 12 Jul 2005 20:12:40 -0000 @@ -318,6 +318,7 @@ { int oldstate = stateMask; int newstate; + boolean toggle = (this instanceof JToggleButton.ToggleButtonModel); if (b) newstate = oldstate | stateflag; @@ -339,6 +340,12 @@ { 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 @@ { 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)); }
_______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches