GUI Commands User GuideVersion 2.1 |
||
Interacting with SwingAction AdaptersThere will be times when you need to interact with Swing's Action framework. ActionCommands
provide Action adapters to support this case. To create an adaptor you simply call
ActionCommand command = ...; // create an adapter with the same properties as the default face Action adapter = command.getActionAdapter(); // this adapter will have the same properties as the menu context Action menuAdapter = command.getActionAdapter(Face.MENU); Installing ShortcutsActionCommands allow you to install shortcuts directly into components using the command accelerator. This mechanism automatically installs the appropriate entries into the input and action maps. This is useful for supporting accelerator keys for commands not contained within menus. The following example installs the "control S" shortcut on a # Command Config save@face.text=_Save@control S // Install the short cut JPanel panel = ...; ActionCommand command = new ActionCommand("save") {...}; command.installShortCut(panel, JComponent.WHEN_IN_FOCUSED_WINDOW); |
||