This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes text based user interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "text based user interface" Watch "text based user interface" New topic

text based user interface

Brett Wiggins

Joined: Mar 23, 2009
Posts: 19

I have started writing a small application to run on a Linux Shell Server and am wondering if there is a way to make a text-only user interface. The program has a few threads that process I/O from a server as well as input from the user. All input and output are printed and captured to the console and what I would like to do is split the console into different sections so server I/O would be printed in one section and user input could be typed in another section.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38057
Too difficult a topic for us beginners.
Joe Ess

Joined: Oct 29, 2001
Posts: 8839

Java has poor console support. Consoles are very OS (and in Unix, shell) specific and Java tries to be platform-independent.
That said, you can use ASCII control characters, like 0x0d (carriage return) or 0x08 (backspace) to control the cursor on a single line. If your console recognizes ANSI escape sequences(I believe bash does), they allow greater flexibility.
If you want a fully-featured GUI, use AWT or Swing.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Joe Ess

Joined: Oct 29, 2001
Posts: 8839

You can try the Java Curses library (curses is popular for building text interfaces on Unix). The examples look pretty impressive (character-based dialogs, scrolling lists, etc.).
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960

Actually, a true console should be considered as having all the graphics capabilities of a Teletype machine. Which is to say, virtually none. However most "glass TTY" devices (and the console windows that simulate them) are more flexible than that.

As Joe pointed out, there's system called "curses" that's designed to replace the wide variety of vendor-specific terminal control codes (escape sequences) with a standardized text-mode UI. While these days you could generally get by using the ANSI escape sequences, curses makes the process much more civilized.

Customer surveys are for companies who didn't pay proper attention to begin with.
Brett Wiggins

Joined: Mar 23, 2009
Posts: 19
Hi guys,

Thanks for the help.I'll be checking out the java Curses Library.
I agree. Here's the link:
subject: text based user interface
Similar Threads
collecting input using arrays
Passed SCJD Bodgitt and Scraper: 353
output as URL
URLyBird Server & DB shutdown
How to take input from screen automatically