|
|||||||||
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(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(ThreadGroup tg,
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(Callable<V> c)
Synchronously execute a Callable and return the result of the call. |
|
static
|
callNow(ThreadGroup tg,
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(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(Component c)
Deprecated. |
|
static ThreadGroup |
getDefaultThreadGroup()
Gets the default ThreadGroup. |
|
static void |
init()
Sets the destroyed flag to false so Runnables are directed at the EventQueues. |
|
static Throwable |
invokeAndWait(Runnable code)
Calls SwingUtilities.invokeAndWait(Runnable code) using the default ThreadGroup |
|
static Throwable |
invokeAndWait(ThreadGroup threadGroup,
Runnable code)
Calls SwingUtilities.invokeAndWait(Runnable code) considering the ThreadGroup to be used |
|
static void |
invokeLater(Runnable code)
Calls SwingUtilities.invokeLater(Runnable code) using the default ThreadGroup. |
|
static void |
invokeLater(ThreadGroup threadGroup,
Runnable code)
Calls SwingUtilities.invokeLater(Runnable code) considering the ThreadGroup to be used |
|
static void |
invokeLaterIfNotEDT(Runnable code)
Initiate a call of the given Runnable.run() method on the event dispatch thread. |
|
static void |
invokeLaterIfNotEDT(ThreadGroup threadGroup,
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(ThreadGroup tg)
Checks whether the current thread (no matter if EventQueue or not) is the correct EventDispatchThread for the current ThreadGroup. |
|
static void |
main(String[] args)
|
|
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(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 ThreadGroup getDefaultThreadGroup()
public static void setDefaultThreadGroup(ThreadGroup tg)
tg
- the default ThreadGroup.public static <V> V callNow(ThreadGroup tg, 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.
tg
- the ThreadGroup to be usedc
- the Callable whose run method should be executed on a ThreadGroup specific EventQueue
null
if no throwable was
thrown.public static <V> V callNow(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> Future<V> callLater(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> Future<V> callLater(ThreadGroup tg, 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 Throwable invokeAndWait(Runnable code)
code
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueue
null
if no throwable was
thrown.public static Throwable invokeAndWait(ThreadGroup threadGroup, 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(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(ThreadGroup threadGroup, 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(Runnable code)
code
- the Runnable whose run method should be executed on a ThreadGroup specific
EventQueuepublic static void invokeLater(ThreadGroup threadGroup, 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(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(ThreadGroup tg)
tg
- the threadGroup to be checked
public static boolean isDestroyed()
public static void init()
destroy()
public static void ensureEventDispatchThread() throws IllegalStateException
event dispatch thread
. If not this method will throw a IllegalStateException
.
IllegalStateException
- if the calling thread is not the
event dispatch thread
@Deprecated public static void ensureEventDispatchThread(Component c) throws IllegalStateException
event dispatch thread
. If not this method will throw a IllegalStateException
.
NOTE: The previous implementation has been checking whether the component is displayable or not. With java 1.4 it has been considered legal practice to construct the UI tree Off-EDT. This has been changed with the newer versions of the JavaVM and the Swing implementation.
IllegalStateException
- if the calling thread is not the
event dispatch thread
public static void main(String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
![]() | Copyright © 2017 levigo holding gmbh. All rights reserved. |