Link to home
Start Free TrialLog in
Avatar of neonaporte
neonaporte

asked on

Java Console Output Formatting

I am trying to write a program in Java that is an interactive program that allows a user to send messages as well as recieve new messages as they come in. Everything works well except I am having a problem with how the program formats the screen.
New Messages arrive and get printed via "System.out.println(message)" which overwrites what the user is typing in (user input is still there but visibly the new message has overwritten it).

My question is : Is there any way to have java reserve the bottom portion of a console for input only while displaying the output on the lines above it? This application runs ONLY in a console and I cannot create a GUI for it.

Thanks!
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of mwstein
mwstein

Use this to read input
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

It should drop a line every time.

As for the formatting of the console, try that link that CEHJ sent above.
Avatar of neonaporte

ASKER

Seems I can't edit the question ...

This is not a question regarding inputting, I already have that portion done.

My question involves using the base JDK and implementing a method that writes output on the line above the line used for input. This is for a text based tool that sends and recieves messages.

Everything works in the logic area except the output onto the screen. Right now the output overwrites the data that the user types on the line. This makes for a very messy interactive program.

This is a simple project that can not use the jcurses library.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
neonaporte:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-- Points for CEHJ

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TimYates
EE Cleanup Volunteer