Client has gui and extra thread (to process socket input and print it out to passes object of type PrintStream). The gui form has new javax.swing.JTextArea()
. I need to pass to thread the object PrintStream
to write to: ClientThreadIn(PrintStream inOutput){...}
. How to create/bind gui JTextArea to accept data form ClientThreadIn
using PrintStream
?
Client:
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
out = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
ClientThreadIn threadIn = new ClientThreadIn(in, System.out); // client passes it's System.out to thread for writing
So JTextArea should be similar to console. It should be able to accept data from Thread (actually Thread writes to PrintStream of gui)... Is there something similar to JTextArea.getInputStream()?