- java.lang.Object
-
- com.googlecode.lanterna.gui2.AbstractTextGUIThread
-
- com.googlecode.lanterna.gui2.SameTextGUIThread
-
- All Implemented Interfaces:
TextGUIThread
public class SameTextGUIThread extends AbstractTextGUIThread
ThisTextGUIThread
implementation is assuming the GUI event thread will be the same as the thread that creates theTextGUI
objects. This means on the thread you create the GUI on, when you are done you pass over control to lanterna and let it manage the GUI for you. When the GUI is done, you'll get back control again over the thread. This is different fromSeparateTextGUIThread
which spawns a new thread that manages the GUI and leaves the current thread for you to handle.Here are two examples of how to use
SameTextGUIThread
:MultiWindowTextGUI textGUI = new MultiWindowTextGUI(new SameTextGUIThread.Factory(), screen); // ... add components ... while(weWantToContinueRunningTheGUI) { if(!textGUI.getGUIThread().processEventsAndUpdate()) { Thread.sleep(1); } } // ... tear down ...
MultiWindowTextGUI textGUI = new MultiWindowTextGUI(new SameTextGUIThread.Factory(), screen); Window window = new MyWindow(); textGUI.addWindowAndWait(window); // This call will run the event/update loop and won't return until "window" is closed // ... tear down ...
- See Also:
SeparateTextGUIThread
,TextGUIThread
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SameTextGUIThread.Factory
Default factory class forSameTextGUIThread
, you need to pass this to theTextGUI
constructor if you want it to use this class-
Nested classes/interfaces inherited from interface com.googlecode.lanterna.gui2.TextGUIThread
TextGUIThread.ExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Thread
guiThread
-
Fields inherited from class com.googlecode.lanterna.gui2.AbstractTextGUIThread
customTasks, exceptionHandler, textGUI
-
-
Constructor Summary
Constructors Modifier Constructor Description private
SameTextGUIThread(TextGUI textGUI)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Thread
getThread()
Returns the Java thread which is processing GUI events and updating the screen-
Methods inherited from class com.googlecode.lanterna.gui2.AbstractTextGUIThread
invokeAndWait, invokeLater, processEventsAndUpdate, setExceptionHandler
-
-
-
-
Constructor Detail
-
SameTextGUIThread
private SameTextGUIThread(TextGUI textGUI)
-
-
Method Detail
-
getThread
public java.lang.Thread getThread()
Description copied from interface:TextGUIThread
Returns the Java thread which is processing GUI events and updating the screen- Returns:
- Thread which is processing events and updating the screen
-
-