0

I want to show an image or a text in a label just for few seconds and then it disappear . Something like this :

lable.setText("data inserted");
//wait two second 
lable.setText(null);

1 Answers1

4

You can use a PauseTransition:

lable.setText("data inserted");
PauseTransition pause = new PauseTransition(Duration.seconds(2));
pause.setOnFinished(e -> lable.setText(null));
pause.play();
James_D
  • 201,275
  • 16
  • 291
  • 322
  • More detailed answer: https://stackoverflow.com/questions/30543619/how-to-use-pausetransition-method-in-javafx – Raashith May 18 '21 at 21:47