|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.levigo.util.swing.TGASwingUtil
public class TGASwingUtil
A ThreadGroupAware replacement for SwingUtilities.invokeLater(), SwingUtilities.invokeAndWait() and SwingUtilities.isEventDispatchThread() considering the correct EventQueue to use in environments where more than one EventQueue may occur, such as in Applets and WebStart.
Constructor Summary | |
---|---|
TGASwingUtil()
|
Method Summary | ||
---|---|---|
static
|
callLater(java.util.concurrent.Callable<V> c)
Schedule the given callable to be called on the EDT and return a Future providing
access to the result of the call. |
|
static
|
callLater(java.lang.ThreadGroup tg,
java.util.concurrent.Callable<V> c)
Schedule the given callable to be called on the EDT and return a Future providing
access to the result of the call. |
|
static
|
callNow(java.util.concurrent.Callable<V> c)
Synchronously execute a Callable and return the result of the call. |
|
static
|
callNow(java.lang.ThreadGroup tg,
java.util.concurrent.Callable<V> c)
Synchronously execute a Callable and return the result of the call. |
|
static void |
destroy()
Stops the ExecutionQueues redirecting Runnables to EventQueues and performs cleanup. |
|
static void |
destroy(java.lang.ThreadGroup tg)
Stops the ExecutionQueues redirecting Runnables to EventQueues and performs cleanup for the ThreadGroup supplied. |
|
static void |
ensureEventDispatchThread()
This method will ensure that the calling thread is the event dispatch thread . |
|
static void |
ensureEventDispatchThread(java.awt.Component c)
This method will (in case of a displayable component) ensure
that the calling thread is the event dispatch thread . |
|
static java.lang.ThreadGroup |
getDefaultThreadGroup()
Gets the default ThreadGroup. |
|
static void |
init()
Sets the destroyed flag to false so Runnables are directed at the EventQueues. |
|
static java.lang.Throwable |
invokeAndWait(java.lang.Runnable code)
Calls SwingUtilities.invokeAndWait(Runnable code) using the default ThreadGroup |
|
static java.lang.Throwable |
invokeAndWait(java.lang.ThreadGroup threadGroup,
java.lang.Runnable code)
Calls SwingUtilities.invokeAndWait(Runnable code) considering the ThreadGroup to be used |
|
static void |
invokeLater(java.lang.Runnable code)
Calls SwingUtilities.invokeLater(Runnable code) using the default ThreadGroup. |
|
static void |
invokeLater(java.lang.ThreadGroup threadGroup,
java.lang.Runnable code)
Calls SwingUtilities.invokeLater(Runnable code) considering the ThreadGroup to be used |
|
static void |
invokeLaterIfNotEDT(java.lang.Runnable code)
Initiate a call of the given Runnable.run() method on the event dispatch thread. |
|
static void |
invokeLaterIfNotEDT(java.lang.ThreadGroup threadGroup,
java.lang.Runnable code)
Initiate a call of the given Runnable.run() method considering the thread group to be
used on the event dispatch thread. |
|
static boolean |
isActive()
Gets the active flag. |
|
static boolean |
isDestroyed()
|
|
static boolean |
isEventDispatchThread()
Checks whether the current thread (no matter if EventQueue or not) is the correct EventDispatchThread for the current ThreadGroup. |
|
static boolean |
isEventDispatchThread(java.lang.ThreadGroup tg)
Checks whether the current thread (no matter if EventQueue or not) is the correct EventDispatchThread for the current ThreadGroup. |
|
static void |
setActive(boolean active)
Sets the active flag. if not active, invokeLater, invokeAndWait and isEventDispatchThread will be called on the regular SwingUtilities. |
|
static void |
setDefaultThreadGroup(java.lang.ThreadGroup tg)
Sets the default ThreadGroup. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TGASwingUtil()
Method Detail |
---|
public static java.lang.ThreadGroup getDefaultThreadGroup()
public static void setDefaultThreadGroup(java.lang.ThreadGroup tg)
tg
- the default ThreadGroup.public static <V> V callNow(java.lang.ThreadGroup tg, java.util.concurrent.Callable<V> c)
Callable
and return the result of the call. If this method is
called off-EDT, the call will block until the callable has been called on the EDT. If it is
called on-EDT, the callable will be called immediately.
threadGroup
- the ThreadGroup to be usedcode
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueue
null
if no throwable was
thrown.public static <V> V callNow(java.util.concurrent.Callable<V> c)
Callable
and return the result of the call. If this method is
called off-EDT, the call will block until the callable has been called on the EDT. If it is
called on-EDT, the callable will be called immediately.
c
- the Callable whose Callable.call()
is to be executed on a ThreadGroup specific
EventQueue
null
if no throwable was
thrown.public static <V> java.util.concurrent.Future<V> callLater(java.util.concurrent.Callable<V> c)
Future
providing
access to the result of the call.
V
- the type of result returned by the callablec
- the Callable whose Callable.call()
is to be executed on a ThreadGroup specific
EventQueue
Future
providing access to the result of the call.public static <V> java.util.concurrent.Future<V> callLater(java.lang.ThreadGroup tg, java.util.concurrent.Callable<V> c)
Future
providing
access to the result of the call.
V
- the type of result returned by the callabletg
- the ThreadGroup to be usedc
- the Callable whose Callable.call()
is to be executed on a ThreadGroup specific
EventQueue
Future
providing access to the result of the call.public static java.lang.Throwable invokeAndWait(java.lang.Runnable code)
code
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueue
null
if no throwable was
thrown.public static java.lang.Throwable invokeAndWait(java.lang.ThreadGroup threadGroup, java.lang.Runnable code)
threadGroup
- the ThreadGroup to be usedcode
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueue
null
if no throwable was
thrown.public static void invokeLaterIfNotEDT(java.lang.Runnable code)
Runnable.run()
method on the event dispatch thread. If the
current thread is already the event dispatch thread the Runnable.run()
method is called
synchronously. Otherwise the Runnable.run()
will be enqueued in the event dispatch
thread to be be called asynchronously.
code
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueueinvokeLaterIfNotEDT(ThreadGroup, Runnable)
,
invokeLater(Runnable)
,
invokeLater(ThreadGroup, Runnable)
,
isEventDispatchThread()
,
isEventDispatchThread(ThreadGroup)
public static void invokeLaterIfNotEDT(java.lang.ThreadGroup threadGroup, java.lang.Runnable code)
Runnable.run()
method considering the thread group to be
used on the event dispatch thread. If the current thread is already the event dispatch thread
for the given thread group the Runnable.run()
method is called synchronously. Otherwise
the Runnable.run()
will be enqueued in the approbate event dispatch thread to be
called asynchronously.
code
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueuethreadGroup
- the ThreadGroup to be usedcode
- the Runnable whose run method should be executed on a thread group specific
EventQueueinvokeLaterIfNotEDT(Runnable)
,
invokeLater(Runnable)
,
invokeLater(ThreadGroup, Runnable)
,
isEventDispatchThread()
,
isEventDispatchThread(ThreadGroup)
public static void invokeLater(java.lang.Runnable code)
code
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueuepublic static void invokeLater(java.lang.ThreadGroup threadGroup, java.lang.Runnable code)
threadGroup
- the ThreadGroup to be usedcode
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueuepublic static void destroy()
public static void destroy(java.lang.ThreadGroup tg)
tg
- the threadGroup to be used for removing the execution queuespublic static boolean isActive()
public static void setActive(boolean active)
active
- the active flag to set.public static boolean isEventDispatchThread()
public static boolean isEventDispatchThread(java.lang.ThreadGroup tg)
the
- threadGroup to be checked
public static boolean isDestroyed()
public static void init()
destroy()
public static void ensureEventDispatchThread() throws java.lang.IllegalStateException
event dispatch thread
. If not this method will throw a IllegalStateException
.
java.lang.IllegalStateException
- if the calling thread is not the
event dispatch thread
public static void ensureEventDispatchThread(java.awt.Component c) throws java.lang.IllegalStateException
displayable
component) ensure
that the calling thread is the event dispatch thread
. If
the component is displayable
(see
Component.isDisplayable()
) and the current thread is not the
event dispatch thread
this method will throw a
IllegalStateException
.
The exception for not yet displayable
components allows the
construction of Swing hierarchies outside the event
dispatch thread
java.lang.IllegalStateException
- if the calling thread is not the
event dispatch thread
and the component is
displayable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |