Package org.pepsoft.util
Class AwtUtils
java.lang.Object
org.pepsoft.util.AwtUtils
Utility methods for working with the AWT.
Created by pepijn on 16-04-15.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddoLaterOnEventThread(Runnable task) Schedule a task for later execution on the event dispatch thread and return immediately.static voiddoLaterOnEventThread(String key, int delay, Runnable task) Schedule a task for later execution on the event dispatch thread and return immediately.static voiddoOnEventThread(Runnable task) Execute a task on the even dispatch thread.static voidExecute a task on the even dispatch thread and wait for it to finish.static <T> TresultOfOnEventThread(Callable<T> task) Execute a task on the event dispatch thread and return the result.
-
Constructor Details
-
AwtUtils
public AwtUtils()
-
-
Method Details
-
resultOfOnEventThread
Execute a task on the event dispatch thread and return the result. The task may be executed on a different thread, so it must be thread-safe. Since it will block the event thread it should be short and to the point.- Type Parameters:
T- The type of the result to return.- Parameters:
task- The task to execute.- Returns:
- The result of the task.
-
doOnEventThread
Execute a task on the even dispatch thread. The task may be executed on a different thread, so it must be thread-safe. Since it will block the event thread it should be short and to the point. If the current thread is not the event dispatch thread this method does not wait for the task to finish.- Parameters:
task- The task to execute.
-
doOnEventThreadAndWait
Execute a task on the even dispatch thread and wait for it to finish. The task may be executed on a different thread, so it must be thread-safe. Since it will block the event thread it should be short and to the point.- Parameters:
task- The task to execute.
-
doLaterOnEventThread
Schedule a task for later execution on the event dispatch thread and return immediately. The task may be executed on a different thread, so it must be thread-safe. Since it will block the event thread it should be short and to the point.- Parameters:
task- The task to execute.
-
doLaterOnEventThread
Schedule a task for later execution on the event dispatch thread and return immediately. The task may be executed on a different thread, so it must be thread-safe. Since it will block the event thread it should be short and to the point.If a task with the same key is already scheduled and has not yet executed that will be superseded.
- Parameters:
key- The unique key of the task. Scheduling a task will supersede a task with the same key that is already scheduled.delay- The minimum number of milliseconds after which the task should be executed.task- The task to execute.
-