|
qflib 0.99 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.EventQueue
de.qfs.lib.gui.EventQueue
This EventQueue enables exception handling for exceptions raised in the AWT event loop thread. Since version 0.98.0 this works even with JDK 1.1.
Additionally, a workaround is provided for a problem with some JDKs on Motif systems (linux for example), where no KEY_PRESSED and KEY_TYPED events are generated for the Shift_Tab combination under certain circumstances. This hack generates the neccessary events so tab traversal works both forwards and backwards.
New in qflib 0.98.0 is another hack needed for some Motif systems like the IBM JDKs on linux: They generate Alt-Key events with the modifier bits for ALT and META set, which causes keyboard access of menus to fail (among other Alt-... bindings). If you enable the meta hack, the META modifier will be removed from these key events.
Yet another hack is needed for the blackdown JDK 1.3 on linux: It generates a KEY_TYPED event for the delete key, causing weird symbols to appear in text components. These events are filtered if the delete hack is enabled. Similarly, the escape key can insert printable characters under certain conditions. The delete hack will remove these as well.
Different ways are used to install an EventQueue as the system event queue
for JDKs 1.1 and 1.2. With JDK 1.1, make sure that the class is in your
CLASSPATH and add the line
AWT.EventQueueClass=de.qfs.lib.gui.EventQueue
to the file
awt.properties
in the lib directory of your JDK. Make sure you
don't put any extra SPACE characters on the line, as some JDKs choke on
them. In any case you must call install
.
Warning: If you use this EventQueue with JDK 1.1 and
install
it, EventQueue.getNextEvent
and EventQueue.peekEvent()
will return WrapperEvents
instead of the normal events and EventQueue.peekEvent(int)
will cease to work. If you want to use these
methods, either check for WrapperEvents and call WrapperEvent.getWrappedEvent
to access the
original event (but dispatch the event through the WrapperEvent's dispatch
method), or temporarily disable the
EventQueue with uninstall
.
Warning: If you use this EventQueue with JDK 1.2 or above,
you must use the EventQueue returned by the instance
method instead of Toolkit.getSystemEventQueue
to poll events with EventQueue.getNextEvent
etc. You can
EventQueue.postEvent
to the system
event queue as usual.
Nested Class Summary | |
static class |
EventQueue.RunnableEvent
ActiveEvent that calls a Runnable from the event dispatch thread. |
class |
EventQueue.WrapperEvent
ActiveEvent that wraps itself around an AWTEvent and dispatches it in JDK 1.2 style through the EventQueue's dispatchEvent method. |
Field Summary | |
protected static java.util.List |
eventFilters
Installed event filters. |
protected boolean |
installed
Whether the queue is currently installed. |
protected java.awt.EventQueue |
originalQueue
Possibly replaced system event queue. |
static int |
RUNNABLE_ID
Id for RunnableEvents. |
protected static EventQueue |
theQueue
The installed Queue or null. |
static int |
WRAPPER_ID
Id for WrapperEvents. |
Constructor Summary | |
EventQueue()
Create a new EventQueue. |
Method Summary | |
static void |
addEventFilter(EventFilter filter)
|
void |
dispatchEvent(java.awt.AWTEvent event)
Dispatch an event. |
protected void |
doDispatch(java.awt.AWTEvent event)
Really dispatch an event. |
protected boolean |
filterEvent(java.awt.AWTEvent event)
Filter an event. |
static boolean |
install()
Install the EventQueue instance as the System EventQueue. |
void |
install(java.awt.EventQueue original,
java.lang.Object appContext)
Install this queue over an original queue. |
static java.awt.EventQueue |
instance()
Get the EventQueue instance, if it has been installed. |
static boolean |
isDeleteHackEnabled()
Query whether the delete hack is enabled. |
static boolean |
isInstalled()
Check, whether the EventQueue has been installed. |
static boolean |
isMetaHackEnabled()
Query whether the meta hack is enabled. |
static boolean |
isTabHackEnabled()
Query whether the tab hack is enabled. |
void |
pop()
Public version of pop. |
static void |
removeEventFilter(EventFilter filter)
|
static void |
setDeleteHackEnabled(boolean enabled)
Set whether the delete hack should be enabled. |
static void |
setExceptionHandler(ExceptionHandler handler)
Set a handler for Exceptions that occur in the AWT event dispatch thread. |
static void |
setMetaHackEnabled(boolean enabled)
Set whether the meta hack should be enabled. |
static void |
setTabHackEnabled(boolean enabled)
Set whether the tab hack should be enabled. |
protected boolean |
tabHack(java.awt.AWTEvent e)
At least on Motif systems (linux for example), no KEY_PRESSED and KEY_TYPED events are generated for the Shift_Tab combination, but only under certain circumstances. |
static void |
uninstall()
Uninstall the EventQueue. |
void |
uninstall(java.lang.Object appContext)
Uninstall the EventQueue. |
Methods inherited from class java.awt.EventQueue |
getCurrentEvent, getMostRecentEventTime, getNextEvent, invokeAndWait, invokeLater, isDispatchThread, peekEvent, peekEvent, postEvent, push |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int WRAPPER_ID
public static final int RUNNABLE_ID
protected static EventQueue theQueue
protected java.awt.EventQueue originalQueue
protected boolean installed
protected static java.util.List eventFilters
Constructor Detail |
public EventQueue()
Method Detail |
public static java.awt.EventQueue instance()
public static boolean install()
public static void uninstall()
public static boolean isInstalled()
public static final boolean isTabHackEnabled()
public static final void setTabHackEnabled(boolean enabled)
enabled
- True to enable the hack.public static final boolean isMetaHackEnabled()
public static final void setMetaHackEnabled(boolean enabled)
enabled
- True to enable the hack.public static final boolean isDeleteHackEnabled()
public static final void setDeleteHackEnabled(boolean enabled)
enabled
- True to enable the hack.public static void addEventFilter(EventFilter filter)
public static void removeEventFilter(EventFilter filter)
public void install(java.awt.EventQueue original, java.lang.Object appContext)
original
- The original queue.appContext
- The AppContext if known or null.public void uninstall(java.lang.Object appContext)
appContext
- The AppContext if known or null.public void dispatchEvent(java.awt.AWTEvent event)
This method is public for the sake of SwingUtil.withEvents
. Don't use it unless you really know what you are
doing.
event
- The event to dispatch.protected void doDispatch(java.awt.AWTEvent event)
event
- The event to dispatch.public void pop()
public static void setExceptionHandler(ExceptionHandler handler)
handler
- The ExceptionHandler to set.protected boolean tabHack(java.awt.AWTEvent e)
e
- The event to check.
protected boolean filterEvent(java.awt.AWTEvent event)
event
- The event to filter.
|
qflib 0.99 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |