相关疑难解决方法(0)

如何在JavaFX2中的任务之间重置进度指示器?

我的主屏幕UI上有一个进度指示器,由各种选项卡和服务共享.每个TabController都有自己的Service实例.在我的MainController类中,对于每个选项卡,我将每个Service的progress属性绑定到ProgressIndicator.

@FXML
Region veil;
@FXML
ProgressIndicator progressDial;

  progressDial.progressProperty().bind(tabController.commandService.progressProperty());
    veil.visibleProperty().bind(tabController.commandService.runningProperty());
    progressDial.visibleProperty().bind(tabController.commandService.runningProperty());
    tabController.commandService.messageProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> ov, String t, String newValue) {
            addCommentary(newValue);
        }
    });
Run Code Online (Sandbox Code Playgroud)

但是我看到,在第一个服务使用它之后,进度拨号不会出现以执行后续服务或任务.我想知道我是否滥用ProgressIndicator,因为每个服务可能同时运行.我猜测第一次完成后进度没有重置.我该如何重置?该progress属性为只读.

ReadOnlyDoubleProperty progressProperty()获取表示进度的ReadOnlyDoubleProperty.

并且调用updateProgress(0)不会使拨号重新出现.

我尝试使用ProgressIndicator作为全局显式重置它

mainController.progressDial.setProgress(0);

但这失败了

java.lang.RuntimeException: A bound value cannot be set. at javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:159)

我可能会弄错,但我认为这是JavaFX UI控件设计中的错误.将进度更新为0应重置进度指示器.

javafx-2

2
推荐指数
1
解决办法
6991
查看次数

标签 统计

javafx-2 ×1