0
我使用下面的代碼來顯示加載任務的進度指示器。我使用的是來自ControlsFX進度指示器的MaskerPane。 但是,當我使用的組件,maskerpane只顯示1次..請建議一個更好的方式來顯示進度指示器。javafx應用程序的進度指示
@FXML
private MaskerPane progressPane;
@FXML
private void addMemberSelect() {
Task task = new Task<Void>() {
@Override
protected Void call() throws Exception {
progressPane.setVisible(true);
return null;
}
@Override
protected void succeeded(){
super.succeeded();
content.setContent(null);
ScreensController colllectScreenController = new ScreensController();
colllectScreenController.loadScreen(Screens.ADD_MEMBER);
colllectScreenController.setScreen(Screens.ADD_MEMBER);
content.setContent(colllectScreenController);
progressPane.setVisible(false);
}
};
new Thread(task).start();
}
你的問題不是很清楚。你想從MaskPane中獲得什麼?什麼不起作用?你是什麼意思,「maskerpane只顯示一次」? – ItachiUchiha
對不起,我的英語。其實我希望在切換場景時顯示進度。每個場景都包含一些數據庫操作。所以我想顯示進度指標。我使用的上述代碼只顯示一次進度 一次。顯示任何進度欄 – boycod3
我沒有看到您使用[updateProgress()]更新進度(https://docs.oracle.com/javase/8/javafx/api/javafx/concurrent/Task.html#updateProgress-double -double-)在任務上。如果您不使用它,進度指示器將永遠不會顯示進度。有多個示例顯示如何在[Task](https://docs.oracle.com/javase/8/javafx/api/javafx/concurrent/Task.html)的javadoc中使用它。 – ItachiUchiha