英文:
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();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论