public class ActionSupportForJDK5
extends java.lang.Object
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.Modifier and Type | Field and 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 and Description |
---|
ActionSupportForJDK5() |
Modifier and Type | Method and 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) |
public static final java.lang.String SELECTED_KEY
public static final java.lang.String DISPLAYED_MNEMONIC_INDEX_KEY
public static final java.lang.String LARGE_ICON_KEY
protected static final java.lang.String CLIENT_PROPERTY_PROPERTY_CHANGE_LISTENER
protected static final java.lang.String CLIENT_PROPERTY_ITEM_LISTENER
public static void setActionSelected(javax.swing.Action action, boolean selected)
public static boolean isActionSelected(javax.swing.Action action)
public static void setDisplayedMnemonicIndex(javax.swing.Action action, int newIndex)
public static boolean hasDisplayedMnemonicIndex(javax.swing.Action action)
public static int getDisplayedMnemonicIndex(javax.swing.Action action)
public static void setLargeIcon(javax.swing.Action action, javax.swing.Icon icon)
public static javax.swing.Icon getLargeIcon(javax.swing.Action action)
public static void install(javax.swing.AbstractButton button, javax.swing.Action action)
public static void install(javax.swing.AbstractButton button)
public static void uninstall(javax.swing.AbstractButton button, javax.swing.Action action)
public static void uninstall(javax.swing.AbstractButton button)
public static void actionPropertyChanged(javax.swing.AbstractButton button, javax.swing.Action action, java.lang.String propertyName)