英文:
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();
专注分享java语言的经验与见解,让所有开发者获益!
评论