JDK-4629461 : Enhancement management of the javax.swing.Action class
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_98
  • CPU: x86
  • Submitted: 2002-01-28
  • Updated: 2002-05-30
  • Resolved: 2002-05-30
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 01/28/2002


FULL PRODUCT VERSION :
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)


FULL OPERATING SYSTEM VERSION :
Windows 98 [Version 4.10.1998]



A DESCRIPTION OF THE PROBLEM :
Management of several GUI component states is not
centralized by the javax.swing.Action class. For example,
there is no way to set the "selected state" of a
JToggleButton, JRadioButton, or JCheckBoxMenuItem. Neither
there is a method like action.setSelected(true), nor the
putValue("selected", new Boolean(true)) works.
Management of several states of GUI components could be
considered: "selected", "selected index"

I am looking for a method like setSelected(boolean) in
javax.swing.Action interface.
For example, look at the following code:

--------------------------------------------------------
Action a = new AbstractAction() {
  public void actionPerformed(ActionEvent e) {
   //doing work
  }
};

JToggleButton b1 = new JToggleButton(a);
JCheckBoxMenuItem m1 = new JCheckBoxMenuItem(a);
--------------------------------------------------------

The "seleted" state of b1 and m1 should be equivalent because they are
referring to the
same action. Currently it is not impossible to set the "selected" state of
both b1 and m1
from the Action object's method, neither a.setSelected(boolean) nor
a.putValue("selected", new Boolean(boolean)), instead I have to access both
b1 and m1
and set their "selected" state one by one, i.e. b1.setSelected(boolean) and
m1.setSelected(boolean).

I suggest to add a setSelected(boolean) method in the javax.swing.Action
interface such that we
could centrally change the "selected" state of components that share the
same Action object.

This bug can be reproduced always.
(Review ID: 138554) 
======================================================================

Comments
EVALUATION Clearly what is needed is support for multi-state Actions which support JToggleButton, Group Buttons, JCheckBoxMenuItem, etc.... The StateChangeAction would proably implement the ItemListener similar to that Action implements ActionListener. Should proably fix this for the next major release. ###@###.### 2002-05-23
23-05-2002