Package com.jidesoft.utils
Class ActionSupportForJDK5
- java.lang.Object
-
- com.jidesoft.utils.ActionSupportForJDK5
-
public class ActionSupportForJDK5 extends java.lang.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.
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.Action action = new AbstractAction("Text") {...}; JButton button = new JButton(action); ActionSupportForJDK5.install(button);
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
CLIENT_PROPERTY_ITEM_LISTENER
protected static java.lang.String
CLIENT_PROPERTY_PROPERTY_CHANGE_LISTENER
static java.lang.String
DISPLAYED_MNEMONIC_INDEX_KEY
static java.lang.String
LARGE_ICON_KEY
static java.lang.String
SELECTED_KEY
-
Constructor Summary
Constructors Constructor Description ActionSupportForJDK5()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
actionPropertyChanged(javax.swing.AbstractButton button, javax.swing.Action action, java.lang.String propertyName)
static int
getDisplayedMnemonicIndex(javax.swing.Action action)
static javax.swing.Icon
getLargeIcon(javax.swing.Action action)
static boolean
hasDisplayedMnemonicIndex(javax.swing.Action action)
static void
install(javax.swing.AbstractButton button)
static void
install(javax.swing.AbstractButton button, javax.swing.Action action)
static boolean
isActionSelected(javax.swing.Action action)
static void
setActionSelected(javax.swing.Action action, boolean selected)
static void
setDisplayedMnemonicIndex(javax.swing.Action action, int newIndex)
static void
setLargeIcon(javax.swing.Action action, javax.swing.Icon icon)
static void
uninstall(javax.swing.AbstractButton button)
static void
uninstall(javax.swing.AbstractButton button, javax.swing.Action action)
-
-
-
Field Detail
-
SELECTED_KEY
public static final java.lang.String SELECTED_KEY
- See Also:
- Constant Field Values
-
DISPLAYED_MNEMONIC_INDEX_KEY
public static final java.lang.String DISPLAYED_MNEMONIC_INDEX_KEY
- See Also:
- Constant Field Values
-
LARGE_ICON_KEY
public static final java.lang.String LARGE_ICON_KEY
- See Also:
- Constant Field Values
-
CLIENT_PROPERTY_PROPERTY_CHANGE_LISTENER
protected static final java.lang.String CLIENT_PROPERTY_PROPERTY_CHANGE_LISTENER
- See Also:
- Constant Field Values
-
CLIENT_PROPERTY_ITEM_LISTENER
protected static final java.lang.String CLIENT_PROPERTY_ITEM_LISTENER
- See Also:
- Constant Field Values
-
-
Method Detail
-
setActionSelected
public static void setActionSelected(javax.swing.Action action, boolean selected)
-
isActionSelected
public static boolean isActionSelected(javax.swing.Action action)
-
setDisplayedMnemonicIndex
public static void setDisplayedMnemonicIndex(javax.swing.Action action, int newIndex)
-
hasDisplayedMnemonicIndex
public static boolean hasDisplayedMnemonicIndex(javax.swing.Action action)
-
getDisplayedMnemonicIndex
public static int getDisplayedMnemonicIndex(javax.swing.Action action)
-
setLargeIcon
public static void setLargeIcon(javax.swing.Action action, javax.swing.Icon icon)
-
getLargeIcon
public static javax.swing.Icon getLargeIcon(javax.swing.Action action)
-
install
public static void install(javax.swing.AbstractButton button, javax.swing.Action action)
-
install
public static void install(javax.swing.AbstractButton button)
-
uninstall
public static void uninstall(javax.swing.AbstractButton button, javax.swing.Action action)
-
uninstall
public static void uninstall(javax.swing.AbstractButton button)
-
actionPropertyChanged
public static void actionPropertyChanged(javax.swing.AbstractButton button, javax.swing.Action action, java.lang.String propertyName)
-
-