Button button = new Button("Show Text");
button.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
Platform.runLater(new Runnable(){
@Override
public void run() {
field.setText("START");
}
});
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
Platform.runLater(new Runnable(){
@Override
public void run() {
field.setText("END");
}
});
}
});
After running the code above, field.setText("START")
is not executed, I mean textfield did not set its text to "START", WHY? How to resolve this?