So i was tried to show data from server to gui jTextArea.setText() for every receive data from server but it only show the latest value.
So this is code from class A:
while (true) {
String receivedCommand = bufferedReader.readLine();
if (receivedCommand != null) {
this.commandFromServer = receivedCommand;
sendCommand(this.commandFromServer);
bufferedWriter.write("Accepted Command");
bufferedWriter.newLine();
bufferedWriter.flush();
if (receivedCommand.equalsIgnoreCase("Disconnect")) {
break;
}
}
}
public void sendCommand(String command) {
MainFrame.getCommandFromServer(command);
}
and this is code from class B:
public static void getCommandFromServer(String command){
System.out.println(command);
chatReceiveText.setText(command);
}
the print out is working as it show the response on console but for textArea.setText is not working as i am expected as it only show latest values after loop is break, how can textArea can set text based on server response?