All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.trumphurst.controls.ContainerKeyTracker

java.lang.Object
   |
   +----com.trumphurst.controls.ContainerFocusTracker
           |
           +----com.trumphurst.controls.ContainerKeyTracker

public class ContainerKeyTracker
extends ContainerFocusTracker
Class to implement hot-keys between components in a Container. Automatically intercepts all keyboard events to all components in the dialog, and passes them to whichever component will handle them.

To use, just create a tracker, passing it the Container you want to deal with.

Note that this extends ContainerFocusTracker, which corrects a bug in Java 1.1 where focus is not handled correctly.

By default, plain letter and number keys are only intercepted from Buttons and Checkboxes. Control and Function keys, Escape, and Enter are intercepted from all components. Note that the interception of the Tab and Enter keys doesn't work in TextComponents. For TextComponents, the Control key is required in conjunction with the Tab or Enter key.

The default behaviour recognises the following components ...

Button
Checkbox
A Checkbox is checked if the first upper case letter of its label is pressed.
Label
The focus is moved to the next focussable component after a Label if the first upper case letter of its label is pressed.

If there are duplicate components that would use the same key, that key is ignored.

Of course, you can modify this default behaviour, by programmatically adding or removing links between a particular key and a Component. You can also turn key trapping and/or key reception on and off for a particular component, or for a whole class of Component. You can also turn the default behaviour on and off.


Constructor Index

 o ContainerKeyTracker(Container)
 o ContainerKeyTracker(Container, boolean)

Method Index

 o addComponent(Component)
 o keyPressed(KeyEvent)
Handle key events which a component does not want.
 o removeComponent(Component)

Constructors

 o ContainerKeyTracker
 public ContainerKeyTracker(Container c,
                            boolean defaultBehaviour)
 o ContainerKeyTracker
 public ContainerKeyTracker(Container c)

Methods

 o keyPressed
 public void keyPressed(KeyEvent e)
Handle key events which a component does not want. These events are passed on manually by the ComponentInfo attached to the Component which is the source of the event.

 o addComponent
 protected void addComponent(Component c)
Overrides:
addComponent in class ContainerFocusTracker
 o removeComponent
 protected void removeComponent(Component c)
Overrides:
removeComponent in class ContainerFocusTracker

All Packages  Class Hierarchy  This Package  Previous  Next  Index