Last active
December 19, 2017 16:17
-
-
Save dant3/216c9f44b15a745ac048 to your computer and use it in GitHub Desktop.
Hello world, in Lanterna 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.googlecode.lanterna.TextColor | |
import com.googlecode.lanterna.gui2._ | |
import com.googlecode.lanterna.screen.Screen | |
import com.googlecode.lanterna.screen.TerminalScreen | |
import com.googlecode.lanterna.terminal.DefaultTerminalFactory | |
object Main { | |
def main(args:Array[String]) = { | |
val terminalFactory = new DefaultTerminalFactory | |
terminalFactory.setSuppressSwingTerminalFrame(true) | |
val terminal = terminalFactory.createTerminal() | |
val screen = new TerminalScreen(terminal) | |
val gui = | |
new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE)) | |
screen.startScreen() | |
gui.addWindowAndWait(new BasicWindow("Hello, world!") { window ⇒ | |
setComponent(new Panel() { | |
addComponent(new Label("Welcome to Lanterna!")) | |
addComponent(new Button("Quit", new Runnable { | |
override def run(): Unit = { | |
println("Quit pressed! Exiting...") | |
window.close() | |
} | |
})) | |
}) | |
}) | |
screen.stopScreen() | |
println("Application finished!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think setSuppresSwingTerminalFrame is deprecated in favour of setForceTextTerminal?