Skip to content

Instantly share code, notes, and snippets.

@dant3
Last active December 19, 2017 16:17
Show Gist options
  • Save dant3/216c9f44b15a745ac048 to your computer and use it in GitHub Desktop.
Save dant3/216c9f44b15a745ac048 to your computer and use it in GitHub Desktop.
Hello world, in Lanterna 3
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!")
}
}
@kaning
Copy link

kaning commented Dec 19, 2017

I think setSuppresSwingTerminalFrame is deprecated in favour of setForceTextTerminal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment