TextGUIThreadSameTextGUIThread, SeparateTextGUIThreadpublic 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, waitgetThreadprotected final TextGUI textGUI
protected TextGUIThread.ExceptionHandler exceptionHandler
public AbstractTextGUIThread(TextGUI textGUI)
AbstractTextGUIThread for operations on the supplies TextGUItextGUI - Text GUI this TextGUIThread implementations will be operating onpublic void invokeLater(Runnable runnable) throws IllegalStateException
TextGUIThreadinvokeLater in interface TextGUIThreadrunnable - Code to run asynchronouslyIllegalStateException - If the GUI thread is not runningpublic void setExceptionHandler(TextGUIThread.ExceptionHandler exceptionHandler)
TextGUIThreadsetExceptionHandler in interface TextGUIThreadexceptionHandler - Handler to inspect exceptionspublic boolean processEventsAndUpdate()
throws IOException
TextGUIThreadfalse) 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 TextGUIThreadtrue if there was anything to process or the GUI was updated, otherwise falseIOException - If there was an I/O error when processing and updating the GUIpublic void invokeAndWait(Runnable runnable) throws IllegalStateException, InterruptedException
TextGUIThreadRunnable and then return.invokeAndWait in interface TextGUIThreadrunnable - 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.