tldr: Here’s a code snippet of a fullscreen terminal window using Lanterna.
Lanterna is an easy way to make text only user interfaces in Java that I highly recommend. One thing that took me too long to find was how to make a window fullscreen. Add:
.setHints(java.util.Collections.singleton(Window.Hint.FULL_SCREEN)); yourWindow
Here’s it in a minimal example:
import java.io.IOException;
import com.googlecode.lanterna.gui2.*;
import com.googlecode.lanterna.screen.*;
import com.googlecode.lanterna.terminal.*;
public class TUI {
public static void main(String[] args) {
;
MultiWindowTextGUI gui;
Screen screen;
BasicWindow window
try (Terminal terminal = new DefaultTerminalFactory().createTerminal()) {
= new TerminalScreen(terminal);
screen .startScreen();
screen
= new MultiWindowTextGUI(screen);
gui
= new BasicWindow();
window .setComponent(new Label("Hello, fullscreen!"));
window// Set window to use fullscreen hint
.setHints(java.util.Collections.singleton(Window.Hint.FULL_SCREEN));
window
.addWindowAndWait(window);
gui} catch (IOException ex) {
}
}
}
Note: There are other hints you can use in Window.Hint
you can use. Put them in a collection and pass them to the setHints
method. I like Window.Hint.NO_DECORATIONS
.
Note: Note: As told in the documentation, “Please note that it’s up to the window manager if these hints will be honored or not.”