I am making a chat program in Java. When a user sends a message to the server, the server sends that message to every other user. The problem is, when a user is typing, he can receive a message, that will be written in the middle of the text he is typing.
A user must always be able to receive messages, while at the same time being able to write without having text appearing in the message he is typing.
Is there any way to do this in Java? A good solution would be to have a part of the console where the messages appear, and another one solely for typing.
It seems that there are libraries similar to ncurses, but are there any solution that doesn't rely on external libraries?
Cleaning the console using ANSI escape codes doesn't help since the text an user is typing might simply disappear because of it.