public abstract class AbstractTextGUIThread extends Object implements TextGUIThread
TextGUIThread.ExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected Queue<Runnable> |
customTasks |
protected TextGUIThread.ExceptionHandler |
exceptionHandler |
protected TextGUI |
textGUI |
Constructor and Description |
---|
AbstractTextGUIThread(TextGUI textGUI) |
Modifier and Type | Method and 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)
public void invokeLater(Runnable runnable) throws IllegalStateException
TextGUIThread
invokeLater
in interface TextGUIThread
runnable
- Code to runIllegalStateException
- 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
public void invokeAndWait(Runnable runnable) throws IllegalStateException, InterruptedException
TextGUIThread
invokeAndWait
in interface TextGUIThread
runnable
- Code to runIllegalStateException
- If the GUI thread is not runningInterruptedException
- If the caller thread was interrupted while waiting for the task to be executedCopyright © 2016. All rights reserved.