|
org.openide.awt 7.8.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openide.awt.Actions
public class Actions
Supporting class for manipulation with menu and toolbar presenters.
Nested Class Summary | |
---|---|
static interface |
Actions.ButtonActionConnector
SPI for supplying alternative implementation of connection between actions and presenters. |
static class |
Actions.CheckboxMenuItem
CheckboxMenuItem extends the java.awt.CheckboxMenuItem and adds a connection to boolean state actions. |
static class |
Actions.MenuItem
Extension of Swing menu item with connection to system actions. |
static class |
Actions.SubMenu
SubMenu provides easy way of displaying submenu items based on SubMenuModel. |
static interface |
Actions.SubMenuModel
Interface for the creating Actions.SubMenu. |
static class |
Actions.ToolbarButton
Deprecated. extends deprecated ToolbarButton |
static class |
Actions.ToolbarToggleButton
Deprecated. extends deprecated ToolbarToggleButton |
Constructor Summary | |
---|---|
Actions()
|
Method Summary | |
---|---|
static Action |
alwaysEnabled(ActionListener delegate,
String displayName,
String iconBase,
boolean noIconInMenu)
Creates new action which is always enabled. |
static void |
connect(AbstractButton button,
Action action)
Connects buttons to action. |
static void |
connect(AbstractButton button,
BooleanStateAction action)
Connects buttons to action. |
static void |
connect(AbstractButton button,
SystemAction action)
Deprecated. Use connect(AbstractButton, Action) instead. |
static void |
connect(JCheckBoxMenuItem item,
BooleanStateAction action,
boolean popup)
Attaches checkbox menu item to boolean state action. |
static void |
connect(JMenuItem item,
Action action,
boolean popup)
Attaches menu item to an action. |
static void |
connect(JMenuItem item,
SystemAction action,
boolean popup)
Deprecated. Use connect(JMenuItem, Action, boolean) instead. |
static String |
cutAmpersand(String text)
Removes an ampersand from a text string; commonly used to strip out unneeded mnemonics. |
static String |
findKey(SystemAction action)
Method that finds the keydescription assigned to this action. |
static void |
setMenuText(AbstractButton item,
String text,
boolean useMnemonic)
Deprecated. Use either AbstractButton.setText(java.lang.String) or Mnemonics.setLocalizedText(AbstractButton, String) as appropriate. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Actions()
Method Detail |
---|
public static String findKey(SystemAction action)
action
- action to find key for
public static void connect(JMenuItem item, SystemAction action, boolean popup)
connect(JMenuItem, Action, boolean)
instead.
item
- menu itemaction
- actionpopup
- create popup or menu itempublic static void connect(JMenuItem item, Action action, boolean popup)
Actions.ButtonActionConnector.connect(JMenuItem, Action, boolean)
and
registering an instance of Actions.ButtonActionConnector
in the
default lookup.
Since version 7.1 the action can also provide properties
"menuText" and "popupText" if one wants to use other text on the JMenuItem
than the name
of the action taken from Action.NAME. The popupText is checked only if the
popup parameter is true and takes the biggest precedence. The menuText is
tested everytime and takes precedence over standard Action.NAME
item
- menu itemaction
- actionpopup
- create popup or menu itempublic static void connect(JCheckBoxMenuItem item, BooleanStateAction action, boolean popup)
item
- menu itemaction
- actionpopup
- create popup or menu itempublic static void connect(AbstractButton button, SystemAction action)
connect(AbstractButton, Action)
instead.
button
- the buttonaction
- the actionpublic static void connect(AbstractButton button, Action action)
SystemAction.iconResource()
for more details.
You can supply an alternative implementation
for this method by implementing method
Actions.ButtonActionConnector.connect(AbstractButton, Action)
and
registering an instance of Actions.ButtonActionConnector
in the
default lookup.
button
- the buttonaction
- the actionpublic static void connect(AbstractButton button, BooleanStateAction action)
button
- the buttonaction
- the actionpublic static void setMenuText(AbstractButton item, String text, boolean useMnemonic)
AbstractButton.setText(java.lang.String)
or Mnemonics.setLocalizedText(AbstractButton, String)
as appropriate.
item
- AbstractButtontext
- new labeluseMnemonic
- if true and '&' char found in new text, next char is used
as Mnemonic.public static String cutAmpersand(String text)
The current implementation behaves in the same way regardless of locale. In case of a conflict it would be necessary to change the behavior based on the current locale.
text
- a localized label that may have mnemonic information in it
public static Action alwaysEnabled(ActionListener delegate, String displayName, String iconBase, boolean noIconInMenu)
<file name="your-pkg-action-id.instance"> <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/> <attr name="delegate" methodvalue="your.pkg.YourAction.factoryMethod"/> <attr name="displayName" bundlevalue="your.pkg.Bundle#key"/> <attr name="iconBase" stringvalue="your/pkg/YourComponent.png"/> <!-- if desired: <attr name="noIconInMenu" boolvalue="false"/> --> </file>In case the "delegate" is not just
ActionListener
, but also
Action
, the returned action acts as a lazy proxy - it defers initialization
of the action itself, but as soon as it is created, it delegates all queries
to it. This way one can create an action that looks statically enabled, and as soon
as user really uses it, it becomes active - it can change its name, it can
change its enabled state, etc.
delegate
- the task to perform when action is invokeddisplayName
- the name of the actioniconBase
- the location to the actions iconnoIconInMenu
- true if this icon shall not have an item in menu
|
org.openide.awt 7.8.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |