任务通过调用updateProgress()来设置其进度,并且具有像ProgressIndicator这样的GUI小部件,其progressProperty绑定到任务的progressProperty.但是,这里的文章还提到在示例5中调用updateMessage,但示例不完整.
http://docs.oracle.com/javafx/2/threads/jfxpub-threads.htm
我不清楚消息的显示位置和方式,因为ProgressIndicator中没有消息属性,也没有ProgressBar将其绑定到.我看到Task从Worker类继承了message属性.http://docs.oracle.com/javafx/2/api/javafx/concurrent/Task.html
但是GUI如何获取它并执行绑定,因为Task只对Service可见?
我找不到这方面的实例.在Ensemble示例中,Service示例具有ProgressIndicator,但同样没有更新消息. http://download.oracle.com/otndocs/products/javafx/2.2/samples/Ensemble/index.html
lik*_*udo 10
我可以使用myController.service.messageProperty()来访问Task的messageProperty.
myTextArea.textProperty().bind(myController.myService.messageProperty());
Run Code Online (Sandbox Code Playgroud)
请注意,这会覆盖TextArea,而不是附加到TextArea.
要执行追加,必须将ChangeListener绑定到message属性.