TextGUIThread
SameTextGUIThread
, SeparateTextGUIThread
public abstract class AbstractTextGUIThread extends Object implements TextGUIThread
TextGUIThread
with common logic for both available concrete implementations.TextGUIThread.ExceptionHandler
Modifier and Type | Field | Description |
---|---|---|
protected Queue<Runnable> |
customTasks |
|
protected TextGUIThread.ExceptionHandler |
exceptionHandler |
|
protected TextGUI |
textGUI |
Constructor | Description |
---|---|
AbstractTextGUIThread(TextGUI textGUI) |
Sets up this
AbstractTextGUIThread for operations on the supplies TextGUI |
Modifier and Type | Method | Description |
---|---|---|
void |
invokeAndWait(Runnable runnable) |
Schedules custom code to be executed on the GUI thread and waits until the code has been executed before
returning.
|
void |
invokeLater(Runnable runnable) |
Invokes custom code on the GUI thread.
|
boolean |
processEventsAndUpdate() |
Main method to call when you are managing the event/input/update loop yourself.
|
void |
setExceptionHandler(TextGUIThread.ExceptionHandler exceptionHandler) |
Updates the exception handler used by this TextGUIThread.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getThread
protected final TextGUI textGUI
protected TextGUIThread.ExceptionHandler exceptionHandler
public AbstractTextGUIThread(TextGUI textGUI)
AbstractTextGUIThread
for operations on the supplies TextGUI
textGUI
- Text GUI this TextGUIThread
implementations will be operating onpublic void invokeLater(Runnable runnable) throws IllegalStateException
TextGUIThread
invokeLater
in interface TextGUIThread
runnable
- Code to run asynchronouslyIllegalStateException
- If the GUI thread is not runningpublic void setExceptionHandler(TextGUIThread.ExceptionHandler exceptionHandler)
TextGUIThread
setExceptionHandler
in interface TextGUIThread
exceptionHandler
- Handler to inspect exceptionspublic boolean processEventsAndUpdate() throws IOException
TextGUIThread
false
) you could sleep for a millisecond and then try again. If you use SameTextGUIThread
you
must either call this method directly to make the GUI update or use one of the methods on
WindowBasedTextGUI
that blocks until a particular window has closed.processEventsAndUpdate
in interface TextGUIThread
true
if there was anything to process or the GUI was updated, otherwise false
IOException
- If there was an I/O error when processing and updating the GUIpublic void invokeAndWait(Runnable runnable) throws IllegalStateException, InterruptedException
TextGUIThread
Runnable
and then return.invokeAndWait
in interface TextGUIThread
runnable
- Code to be run and waited for completion before this method returnsIllegalStateException
- If the GUI thread is not runningInterruptedException
- If the caller thread was interrupted while waiting for the task to be executedCopyright © 2020. All rights reserved.