AsynchronousTextGUIThread
AbstractTextGUIThread
, SameTextGUIThread
, SeparateTextGUIThread
public interface TextGUIThread
TextGUI
. There
are mainly two implementations of this interface, one for having lanterna automatically spawn a new thread for doing
all the processing and leaving the creator thread free to do other things, and one that assumes the creator thread
will hand over control to lanterna for as long as the GUI is running.SameTextGUIThread
,
SeparateTextGUIThread
Modifier and Type | Interface | Description |
---|---|---|
static interface |
TextGUIThread.ExceptionHandler |
This interface defines an exception handler, that is used for looking at exceptions that occurs during the main
event loop of the TextGUIThread.
|
Modifier and Type | Method | Description |
---|---|---|
Thread |
getThread() |
Returns the Java thread which is processing GUI events and updating the screen
|
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.
|
void invokeLater(Runnable runnable) throws IllegalStateException
runnable
- Code to run asynchronouslyIllegalStateException
- If the GUI thread is not runningboolean processEventsAndUpdate() throws IOException
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.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 GUIvoid invokeAndWait(Runnable runnable) throws IllegalStateException, InterruptedException
Runnable
and then return.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 executedvoid setExceptionHandler(TextGUIThread.ExceptionHandler exceptionHandler)
exceptionHandler
- Handler to inspect exceptionsThread getThread()
Copyright © 2020. All rights reserved.