|
qflib 0.98.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.qfs.lib.gui.EventQueueMark
This little tool is useful to distinguish between artificial and user-generated events. Often it is necessary to decide, whether an event, e.g. a change in some component's selection, was generated by the application itself in responce to a certain action (in which case it should be ignored), or was caused explicitely by the user (so some response is required).
To determine whether an event is artificial, create an EventQueueMark and
activate
it right before and after the action that
causes the event - before to ignore artificial events that are passed to
listeners directly, bypassing the event queue, and after to ignore events
collected on the queue during the action. In the corresponding listener,
use isActive
to determine whether the mark is still
active on the event queue, meaning the event can be ignored.
If the artificial event is not generated immediately, but after some delay,
use activate(int delay)
with a similar, possibly
slightly longer delay.
Field Summary | |
protected boolean |
active
Flag to determine whether the mark is active. |
protected int |
toClear
That many incantations need to be cleared. |
protected int |
toSkip
That many clearances need to be skipped. |
Constructor Summary | |
EventQueueMark()
Create a new EventQueueMark. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
Called when a timer fires. |
void |
activate()
Activate the mark until the the events currently on the event queue are removed. |
void |
activate(int delay)
Activate the mark until some time has passed. |
void |
deactivate()
Deactivate the mark immediately. |
boolean |
isActive()
Check whether the mark is active. |
void |
run()
Zun method for SwingUtilities.invokeLater . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean active
protected int toClear
protected int toSkip
Constructor Detail |
public EventQueueMark()
Method Detail |
public void activate()
public void activate(int delay)
delay
- The time to wait in ms.public void deactivate()
public boolean isActive()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- Ignored.public void run()
SwingUtilities.invokeLater
. Decrement active count and deactivate the
mark if it reaches 0.run
in interface java.lang.Runnable
|
qflib 0.98.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |