[java] Console Input Question

Started by
2 comments, last by Xorcist 20 years, 9 months ago
Hi, I''m writing a simple relay chat "Broadcast" client/server application (using standard console). Everything works great, but I ran into a situation which is a bit unpleasant. If a user is typing a message while another message comes in, that message gets displayed and breaks the line on which the use was typing his/her message. This is due to the multi-threaded aspect. My question is, is there any way to nicely kill the currently typed line or overwrite it with incoming one, while pushing the line being typing down. Yeah I know I could use a GUI, but that''s not what I''m after. Any ideas? I tried outputting a newline and then the incoming message followed by another newline and the users name, but what ends up happening is that every incoming message dumps a new empty line there, which is worst than the previous case. Does Java have any console type commands to position the cursor and whatnot?
Advertisement
Note: I''m not using the Java "Console" object... should I be?
If you want to do a chat, I suggest just creating a gui.

Another option is make a queue that received the messages from the net, and when you press enter, put your message at the end of the queue, and display what''s there. It won''t be automatically refreshing, but you won''t lose what you''re typing.
Thanks, that sounds like an easy enough solution.

This topic is closed to new replies.

Advertisement