|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.lucidviews.util.gui.event.IsolatedKeyEventProcessor
public class IsolatedKeyEventProcessor
Listens for key events and isolates a single key press.
For each key event a thread is started which causes a delay before sending
the actual notification for that key press. If another key event is received
within the tolerance (delay) time slot then both events are cancelled.
| Nested Class Summary | |
|---|---|
static class |
IsolatedKeyEventProcessor.IsolationThread
|
| Field Summary | |
|---|---|
protected IsolatedKeyEventProcessor.IsolationThread |
_isolationThread
|
protected Collection |
_listeners
|
protected long |
_tolerance
|
| Constructor Summary | |
|---|---|
IsolatedKeyEventProcessor(long tolerance)
Create a processor for key events which only accepts isolated key events (those which occur apart by least the tolerance). |
|
| Method Summary | |
|---|---|
void |
addIsolatedKeyEventListener(IsolatedKeyEventListener listener)
Register a listener that wants to be notified of isolated key press events. |
void |
keyPressed(KeyEvent e)
|
void |
keyReleased(KeyEvent e)
|
void |
keyTyped(KeyEvent e)
|
protected void |
notifyIsolatedKeyPress(KeyEvent keyEvent)
Notify all listeners that an isolated key press has occurred. |
void |
removeIsolatedKeyEventListener(IsolatedKeyEventListener listener)
Un-register a listener that does not want to be notified of isolated key press events. |
protected void |
startIsolationThread(KeyEvent keyEvent)
Start a new isolation thread to verify a given key event is isolated. |
protected void |
stopIsolationThread(IsolatedKeyEventProcessor.IsolationThread isolationThread)
Stop an isolation thread. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Collection _listeners
protected long _tolerance
protected IsolatedKeyEventProcessor.IsolationThread _isolationThread
| Constructor Detail |
|---|
public IsolatedKeyEventProcessor(long tolerance)
tolerance - the isolation tolerance, in milli-seconds| Method Detail |
|---|
public void keyTyped(KeyEvent e)
keyTyped in interface KeyListenerpublic void keyPressed(KeyEvent e)
keyPressed in interface KeyListenerpublic void keyReleased(KeyEvent e)
keyReleased in interface KeyListenerpublic void addIsolatedKeyEventListener(IsolatedKeyEventListener listener)
listener - object that is to receive notificationspublic void removeIsolatedKeyEventListener(IsolatedKeyEventListener listener)
listener - object that is no longer to receive notificationsprotected void notifyIsolatedKeyPress(KeyEvent keyEvent)
keyEvent - the key event associated with the isolated key pressprotected void startIsolationThread(KeyEvent keyEvent)
keyPressed method. It will
pass control of processing the key event to the
IsolationThread::run method.
keyEvent - the incoming key eventprotected void stopIsolationThread(IsolatedKeyEventProcessor.IsolationThread isolationThread)
IsolationThread::run method. It
will check the event has been successfully isolated before calling the
notifyIsolatedKeyPress which will pass control of processing
the key event to any listeners.
isolationThread - the thread which may have isolated a key event
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||