javax.swing
Class SystemEventQueueUtilities

java.lang.Object
  |
  +--javax.swing.SystemEventQueueUtilities

class SystemEventQueueUtilities
extends Object

Swing internal utilities for dealing with the AWT system event queue. Four methods are exported, see the individual method javadoc for more information: addRunnableCanvas(), removeRunnableCanvas(), postRunnable(), queueComponentWorkRequest(). Note: most of the code in this class is no longer needed since we're no longer supporting Swing in 1.1.x VM's and in 1.2 we're guaranteed access to the AWT event queue. However all of the entry points, save postRunnable(), are still used.

See Also:
RepaintManager, JRootPane

Field Summary
private static Object classLock
           
private static Object rootTableKey
           
 
Constructor Summary
(package private) SystemEventQueueUtilities()
           
 
Method Summary
(package private) static void addRunnableCanvas(JRootPane rootPane)
          Associate a RunnableCanvas and a JRootPane to enable queuing events for the root pane's parent window's event dispatching thread.
private static Map getRootTable()
           
private static ThreadGroup getThreadGroupSafely()
          Return the current threads ThreadGroup, even on IE4.0.
(package private) static Exception postRunnable(Runnable doRun, Object lock)
          Post an event to the AWT System event queue that, when dispatched, will invoke the specified Runnable.
private static void postRunnableCanvasEvent(javax.swing.SystemEventQueueUtilities.RunnableEvent e)
          Synchronized entry point to the applet support for AWT System event queue access.
private static void processRunnableEvent(javax.swing.SystemEventQueueUtilities.RunnableEvent runnableEvent)
          Calls RunnableEvent.doRun.run().
(package private) static void queueComponentWorkRequest(Component root)
          This method is used by RepaintManager to queue a ComponentWorkRequest with invokeLater().
(package private) static void removeRunnableCanvas(JRootPane rootPane)
          Remove the RunnableCanvas from the JRootPane and clear the internal bookeeping associated with it.
(package private) static void restartTimerQueueThread()
          Adds a RunnableEvent to all the remaining RunnableCanvases to restart the TimerQueues thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classLock

private static final Object classLock

rootTableKey

private static final Object rootTableKey
Constructor Detail

SystemEventQueueUtilities

SystemEventQueueUtilities()
Method Detail

getRootTable

private static Map getRootTable()

queueComponentWorkRequest

static void queueComponentWorkRequest(Component root)
This method is used by RepaintManager to queue a ComponentWorkRequest with invokeLater(). It assumes that the root argument is either and Applet or a Window, the root passed in obtained in a slightly different manner than see SwingUtilities.getRoot(). If this called with the root obtained in a different way than RepaintManager currently uses, be sure to also tweak removeRunnableCanvas.


addRunnableCanvas

static void addRunnableCanvas(JRootPane rootPane)
Associate a RunnableCanvas and a JRootPane to enable queuing events for the root pane's parent window's event dispatching thread. Adds a 1x1 RunnableCanvas to the root pane's layered pane.

Called by JRootPane.addNotify() to set up the RunnableCanvas.

See Also:
RunnableCanvas, JRootPane.addNotify()

removeRunnableCanvas

static void removeRunnableCanvas(JRootPane rootPane)
Remove the RunnableCanvas from the JRootPane and clear the internal bookeeping associated with it.

Called by JRootPane.removeNotify()

See Also:
RunnableCanvas

postRunnable

static Exception postRunnable(Runnable doRun,
                              Object lock)
Post an event to the AWT System event queue that, when dispatched, will invoke the specified Runnable. If lock is non-null this call blocks (by waiting on the lock) until the doRun() method returns, otherwise we return as soon as the event has been enqueued. An exception is only returned if lock is non-null, i.e. if we're being called from invokeAndWait().

This method is only intended to support SwingUtilities.invokeLater() and SwingUtilities.invokeAndWait().


restartTimerQueueThread

static void restartTimerQueueThread()
Adds a RunnableEvent to all the remaining RunnableCanvases to restart the TimerQueues thread.

See Also:
RunnableCanvas.postRunnableEventToAll(javax.swing.SystemEventQueueUtilities.RunnableEvent)

processRunnableEvent

private static void processRunnableEvent(javax.swing.SystemEventQueueUtilities.RunnableEvent runnableEvent)
Calls RunnableEvent.doRun.run(). If RunnableEvent.lock is non null then we synchronize the run() call and save the exception (if any) in the RunnableEvent.exception field.


postRunnableCanvasEvent

private static void postRunnableCanvasEvent(javax.swing.SystemEventQueueUtilities.RunnableEvent e)
Synchronized entry point to the applet support for AWT System event queue access. This method adds the event to the appropriate runnable canvas's queue and then has the canvas repaint(). Note that by the time the event dispatching thread gets to handling the repaint() (by calling runnableCanvas.update()), many runnable events may have been queued up.

See Also:
RunnableCanvas.addRunnableEvent(javax.swing.SystemEventQueueUtilities.RunnableEvent), RunnableCanvas.update(java.awt.Graphics)

getThreadGroupSafely

private static ThreadGroup getThreadGroupSafely()
Return the current threads ThreadGroup, even on IE4.0. IE4.0 throws a SecurityException if you apply getThreadGroup() to the event dispatching thread. However a child of the event dispatching thread (same thread group) is OK.



comments?