public class AcceleratorGroup extends Object
Ctrl+Ois the typical accelerator for opening a file. Accelerator in this case refers to pressing these keys together and the action that results.
When a key binding is pressed the action related to the Widget is being
activated. Therefore each key binding is directly tied to the Widget in
question. You generally only need one AcceleratorGroup object per Window.
Create one, then tell the toplevel about it with Window's
Key bindings are only bound to MenuItems or Actions. For example, given a Window, a Menu, and a MenuItem, we setup an AcceleratorGroup for the toplevel and then assign a key binding to the MenuItem:
group = new AcceleratorGroup(); window.addAcceleratorGroup(group); .. menu.setAcceleratorGroup(group); item.setAccelerator(group, Keyval.O, ModifierType.CONTROL_MASK);
For ImageMenuItem you can either use the key binding that is associated with it through the Stock item and only invoke:
imageitem.setAccelerator(group);or you can set a custom key binding through the method from parent class MenuItem:
imageitem.setAccelerator(group, Keyval.N, ModifierType.CONTROL_MASK);
In order to set multiple Modifier Types you can use the static method
|Constructor and Description|