AsynchronousTextGUIThread
, TextGUIThread
public class SeparateTextGUIThread extends AbstractTextGUIThread implements AsynchronousTextGUIThread
start()
for this. The GUI thread will stop if stop()
is called, the input stream returns EOF or an exception is
thrown from inside the event handling loop.
Here is an example of how to use this TextGUIThread
:
MultiWindowTextGUI textGUI = new MultiWindowTextGUI(new SeparateTextGUIThread.Factory(), screen);
// ... add components ...
((AsynchronousTextGUIThread)textGUI.getGUIThread()).start();
// ... this thread will continue while the GUI runs on a separate thread ...
TextGUIThread
,
SameTextGUIThread
Modifier and Type | Class | Description |
---|---|---|
static class |
SeparateTextGUIThread.Factory |
Factory class for creating SeparateTextGUIThread objects
|
AsynchronousTextGUIThread.State
TextGUIThread.ExceptionHandler
customTasks, exceptionHandler, textGUI
Modifier and Type | Method | Description |
---|---|---|
AsynchronousTextGUIThread.State |
getState() |
Returns the current status of this GUI thread
|
Thread |
getThread() |
Returns the Java thread which is processing GUI events and updating the screen
|
void |
invokeLater(Runnable runnable) |
Invokes custom code on the GUI thread.
|
void |
start() |
Starts the AsynchronousTextGUIThread, typically meaning that the event processing loop will start.
|
void |
stop() |
Requests that the AsynchronousTextGUIThread stops, typically meaning that the event processing loop will exit
|
void |
waitForStop() |
Blocks until the GUI loop has stopped
|
invokeAndWait, processEventsAndUpdate, setExceptionHandler
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
invokeAndWait, processEventsAndUpdate, setExceptionHandler
public void start()
AsynchronousTextGUIThread
start
in interface AsynchronousTextGUIThread
public void stop()
AsynchronousTextGUIThread
stop
in interface AsynchronousTextGUIThread
public void waitForStop() throws InterruptedException
AsynchronousTextGUIThread
waitForStop
in interface AsynchronousTextGUIThread
InterruptedException
- In case this thread was interrupted while waiting for the GUI thread to exitpublic AsynchronousTextGUIThread.State getState()
AsynchronousTextGUIThread
getState
in interface AsynchronousTextGUIThread
public Thread getThread()
TextGUIThread
getThread
in interface TextGUIThread
public void invokeLater(Runnable runnable) throws IllegalStateException
TextGUIThread
invokeLater
in interface TextGUIThread
invokeLater
in class AbstractTextGUIThread
runnable
- Code to run asynchronouslyIllegalStateException
- If the GUI thread is not runningCopyright © 2020. All rights reserved.