I am working on a project for receiving data from client sockets. The user interface contains a Text Area to show the received data.
What is the best way to pass the received data from the servers threads back to text area?
Currently what i do is the following.
- start the JFrame Java Application
- Create a Server object and pass the JTextArea object to it.
- Start the socket server in a separate thread
- when new message received form a client, the thread update the JTextArea field like following
jtextarea.setText(newMessage);
Is my approach correct?