Search code examples
javancursestui

What's the best way to get text user-interfaces (ncurses-like) functionality in Java?


I need to implement a console application (possibly in Java) with ncurses-like functionality (such as navigating a menu and redrawing the whole screen).

The only solutions that I can find to do this so far are CHARVA ("A Java Windowing Toolkit for Text Terminals"), tuipeer ("A Text User Interface for the Java AWT") and a really old Dr. Dobb's article ("A Text UI for the Java AWT ").

So far, CHARVA is the best thing that I can find but I don't like the idea of it using JNI to wrap curses.

Is there any standard way, say with AWT/Swing, to do do this? What other alternatives are there?


Solution

  • Since 2010 there is Lanterna :

    Lanterna is a Java library allowing you to write easy semi-graphical user interfaces in a text-only environment, very similar to the C library curses but with more functionality. Lanterna is supporting xterm compatible terminals and terminal emulators such as konsole, gnome-terminal, putty, xterm and many more. One of the main benefits of lanterna is that it's not dependent on any native library but runs 100% in pure Java.

    More here: https://github.com/mabe02/lanterna