这并没有改变我的标签。只有第一个运行而其他人不会改变。在Java中它起作用但在Javafx中并没有。
<script>
jQuery(document).on("click",".consult-header .consult-primary-menu li a",function(event){
event.preventDefault();
var thishref =jQuery(this).attr("href");
var url = thishref.substr(thishref.indexOf("#"));
jQuery('html, body').animate({
scrollTop: $(url).offset().top
}, 2000);
});
</script>
答案 0 :(得分:0)
当您调用Thread.sleep(40);
时,您实际上是在停止JavaFX应用程序线程,并且不会有GUI更新。正如评论中指出的那样,您不应该暂停申请线程。
您可以从其他主题进行更新:
Task<Void> loadTask = new Task<Void>() {
@Override
protected Void call() throws Exception {
for (int i = 0; i <= 200; i++) {
Thread.sleep(40);
String text = "";
if (i <= 30)
text = "Initilizing Components...";
else if (i <= 50)
text = "Initializing Database Connection...";
else if (i <= 80)
text = "Initializing User Interface...";
else
text = "Please wait...";
String finalText = text;
Platform.runLater(() -> lblLoad.setText(finalText));
}
return null;
}
};
new Thread(loadTask).start();
答案 1 :(得分:0)
您可以将javafx.animation.Timeline
用于定期活动:
int counter=0;
Timeline doEvery40sec = new Timeline(new KeyFrame(Duration.seconds(40), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if(counter==0)
lblLoad.setText("Initilizing Components...");
}else if(counter==1){
lblLoad.setText("Initializing Database Connection...");
}else if(counter==2){
lblLoad.setText("Initializing User Interface...");
}else if(counter==3)
lblLoad.setText("Please wait...");
counter++;
}
}));
fiveSecondsWonder.setCycleCount(4);
fiveSecondsWonder.play();