如何在JavaFX中在几秒钟内显示和隐藏图像。

huangapple go评论73阅读模式
英文:

how to show and hide an image for few seconds in javafx

问题

我想在标签中显示一张图片或一段文本,仅持续几秒钟,然后它会消失。就像这样:

label.setText("已插入数据");
// 等待两秒钟
label.setText(null);
英文:

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

得分: 4

你可以使用 PauseTransition:

lable.setText("data inserted");
PauseTransition pause = new PauseTransition(Duration.seconds(2));
pause.setOnFinished(e -> lable.setText(null));
pause.play();
英文:

You can use a PauseTransition:

lable.setText("data inserted");
PauseTransition pause = new PauseTransition(Duration.seconds(2));
pause.setOnFinished(e -> lable.setText(null));
pause.play();

huangapple
  • 本文由 发表于 2020年3月16日 04:05:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/60697125.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定