I have a simple JavaFX application that has TextArea. I can update the contents of textArea using the code below inside the start () method:
new Thread(new Runnable() { public void run() { for (int i = 0; i < 2000; i++) { Platform.runLater(new Runnable() { public void run() { txtarea.appendText("text\n"); } }); } } }).start();
The code simply writes the string text
to TextArea 2,000 times. I want to update this textArea function from a function that is implemented outside the start () method.
public void appendText(String p){ txtarea.appendText(p); }
This function can be called from arbitrary programs that use the JavaFX application to update TextArea. How to do this in appendText function?
source share