JIDE 3.5.15

com.jidesoft.utils
Class ActionSupportForJDK5

java.lang.Object
  extended by com.jidesoft.utils.ActionSupportForJDK5

public class ActionSupportForJDK5
extends Object

In JDK6, Swing adds three new properties on Action class: SELECTED_KEY, DISPLAYED_MNEMONIC_INDEX_KEY and LARGE_ICON. You can find more information at http://weblogs.java.net/blog/zixle/archive/2005/11/changes_to_acti.html

However, for users who are still using JDK5, you are out of luck. In this class, we provide a simple way to use those new properties on JDK5.

First of all, you need to call this method.

 Action action = new AbstractAction("Text") {...};
 JButton button = new JButton(action);
 ActionSupportForJDK5.install(button);
 

When you about to change the selected state of action, you call ActionSupportForJDK5.setActionSelected(action, selected). The selected value could be true or false. This call will automatically make the button selected or not selected.

There are also setDisplayedMnemonicIndex and setLargeIcon methods on ActionSupportForJDK5 to the other two new properties.

Last but not least, if you don't use the button anymore, it is a good practice to call ActionSupportForJDK5.uninstall to remove the installed listeners.


Field Summary
protected static String CLIENT_PROPERTY_ITEM_LISTENER
           
protected static String CLIENT_PROPERTY_PROPERTY_CHANGE_LISTENER
           
static String DISPLAYED_MNEMONIC_INDEX_KEY
           
static String LARGE_ICON_KEY
           
static String SELECTED_KEY
           
 
Constructor Summary
ActionSupportForJDK5()
           
 
Method Summary
static void actionPropertyChanged(AbstractButton button, Action action, String propertyName)
           
static int getDisplayedMnemonicIndex(Action action)
           
static Icon getLargeIcon(Action action)
           
static boolean hasDisplayedMnemonicIndex(Action action)
           
static void install(AbstractButton button)
           
static void install(AbstractButton button, Action action)
           
static boolean isActionSelected(Action action)
           
static void setActionSelected(Action action, boolean selected)
           
static void setDisplayedMnemonicIndex(Action action, int newIndex)
           
static void setLargeIcon(Action action, Icon icon)
           
static void uninstall(AbstractButton button)
           
static void uninstall(AbstractButton button, Action action)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTED_KEY

public static final String SELECTED_KEY
See Also:
Constant Field Values

DISPLAYED_MNEMONIC_INDEX_KEY

public static final String DISPLAYED_MNEMONIC_INDEX_KEY
See Also:
Constant Field Values

LARGE_ICON_KEY

public static final String LARGE_ICON_KEY
See Also:
Constant Field Values

CLIENT_PROPERTY_PROPERTY_CHANGE_LISTENER

protected static final String CLIENT_PROPERTY_PROPERTY_CHANGE_LISTENER
See Also:
Constant Field Values

CLIENT_PROPERTY_ITEM_LISTENER

protected static final String CLIENT_PROPERTY_ITEM_LISTENER
See Also:
Constant Field Values
Constructor Detail

ActionSupportForJDK5

public ActionSupportForJDK5()
Method Detail

setActionSelected

public static void setActionSelected(Action action,
                                     boolean selected)

isActionSelected

public static boolean isActionSelected(Action action)

setDisplayedMnemonicIndex

public static void setDisplayedMnemonicIndex(Action action,
                                             int newIndex)

hasDisplayedMnemonicIndex

public static boolean hasDisplayedMnemonicIndex(Action action)

getDisplayedMnemonicIndex

public static int getDisplayedMnemonicIndex(Action action)

setLargeIcon

public static void setLargeIcon(Action action,
                                Icon icon)

getLargeIcon

public static Icon getLargeIcon(Action action)

install

public static void install(AbstractButton button,
                           Action action)

install

public static void install(AbstractButton button)

uninstall

public static void uninstall(AbstractButton button,
                             Action action)

uninstall

public static void uninstall(AbstractButton button)

actionPropertyChanged

public static void actionPropertyChanged(AbstractButton button,
                                         Action action,
                                         String propertyName)

JIDE 3.5.15