So, I know that the JavaFx update method when using a thread is called Task, but is the code working the same way or is there any difference. let me give an example of a swing:
Another class outside the GUI that works like a thread
public void run(){ while (socket.isConnected()) { String x = input.next(); System.out.println(x); mg.updateChat(x) } }
Inside GUI
public void updateChat(final String input){ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { txtChat.setText(input); } }); }
Does the task work exactly the same? Or are there differences, and is there a way to change this code to work in a JavaFx project?
java swing javafx event-dispatch-thread
Marc rasmussen
source share