JDK-4491747 : RFE: Use of Action still needs work
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0,1.4.0,1.4.1_01
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS:
    generic,linux,linux_redhat_7.2,windows_2000 generic,linux,linux_redhat_7.2,windows_2000
  • CPU: generic,x86
  • Submitted: 2001-08-14
  • Updated: 2017-05-16
  • Resolved: 2005-08-26
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Name: yyT116575			Date: 08/14/2001

java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

Swing components use of Action still needs some work.

The changes to 1.4.0beta (4304129 4396593) are incomplete.

    This needs an Action.ENABLED_KEY.

    Action.ACTION_COMMAND_KEY is not used at all.

    This provides a mechanism for extending classes
    to specify which action properties are used when
    the action is set but does not provide the same
    mechanism when the action changes.

    The configurePropertiesFromAction method is also
    inefficient as it creates a new array every time
    that the types array is not specified. This array
    should be static and the method should state that
    it does not change the array so that extending
    classes can also pass in a static array.

    Action.ACTION_COMMAND_KEY is not used at all.

    Action.ACCELERATOR_KEY is used when the
    action is set, but not when the actions is changed.

    Action.ACTION_COMMAND_KEY is not used at all.

    Action.ACTION_COMMAND_KEY is not used at all.

    Action.ACTION_COMMAND_KEY is not used at all.

    Action.ACTION_COMMAND_KEY is not used at all.

hideActionText property
    This still does not work properly and is the wrong
    way to do this anyway. It does not work because it
    is only supposed to be set when the action has an
    icon configured. However, JToolBar only sets it when
    the button is created, not when the action changes.

    The proper way to do this is for JToolBar to create
    its own button.

Update all actions properties
    It would be nice if the action property change
    listeners would reconfigure all the properties
    from the action if the property name was null.
    This would for example allow ProxyActions to
    more efficiently force an update when the action
    which they are wrapping changes.

    This is a very easy change to make as the Action
    is the source of the event and can simply be
    passed to the configurePropertiesFromAction.

Make ...ActionPropertyChangeListeners extensible
    The various classes which are used to listen to
    changes in Action properties are either anonymous,
    private or package private, this hinders anyone
    wishing to extend the classes. The anonymous
    ones should be named and should be made protected,
    the private classes should be made protected
    and the package private classes should be made

Better solution to allow configuration
    Rather than requiring classes which extend
    AbstractButton from passing in an array of
    properties to check, AbstractButton should
    call a method to retrieve the array of
    properties. This method could then be used
    by both the configurePropertiesFromAction
    method and the action property change
(Review ID: 129998) 

Add another property for a second icon to Action. The
problem is that at the moment I can only define one icon.
This icon will be used for JMenuItems and JToolBar buttons.

The JMenuItem looks better with an icon of 16x16 pixels.
The JToolBar button looks better with an icon of 24x24 pixels.

I've to set ont of the icons manually. It would be better to
have both icons in the Action and both (the button and the
menu item) can get the appropriate icon.

Add another property to Action to have two different buttons.

This bug can be reproduced always.

Set one icon manually.
(Review ID: 143303) 

Should add convenience methods to AbstractAction which can retrieve all the Action
properties from the internal table. All the Action keys should have matching methods.

i.e, action.getName(), intead of (String)action.getValue(Action.NAME),

EVALUATION I'm closing this out as a duplicate of 4133141. Rest assured all of the changes recommended in this bug (with the exception of exposing the private inner classes) will be done as part of that bug. Refer to it for more details and status. Also, we won't be adding: This needs an Action.ENABLED_KEY. It would be nice, but at this point there is no point in having both, it's just confusing and for compatability we would *always* have to call isEnabled anyway.

EVALUATION This is a detailed report that could be the driver for Action improvements for the next release. ###@###.### 2001-11-16 We can't address this in time for tiger. We are still working on a revamp of the Actions framework but it will not make it into 1.5. ###@###.### 2003-12-08