Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX Task: where does updateMessage() write to?

Tags:

javafx-2

A task sets its progress by calling updateProgress(), and having a GUI widget like a ProgressIndicator having its progressProperty bound to the task's progressProperty. However, the article here also mentions calling updateMessage in Example 5 but the example is incomplete.

http://docs.oracle.com/javafx/2/threads/jfxpub-threads.htm

It is not clear to me where/how the message is displayed since there is no message property in ProgressIndicator nor ProgressBar to bind it to. I see that Task inherits message property from Worker class. http://docs.oracle.com/javafx/2/api/javafx/concurrent/Task.html

But how will the GUI get a hold of it and perform the binding since Task is visible only to Service?

I couldn't find working examples of this. In the Ensemble sample, the Service example has a ProgressIndicator but again, no message is updated. http://download.oracle.com/otndocs/products/javafx/2.2/samples/Ensemble/index.html

like image 669
likejudo Avatar asked Jan 13 '13 01:01

likejudo


1 Answers

I am able to use myController.service.messageProperty() to access the messageProperty of Task.

 myTextArea.textProperty().bind(myController.myService.messageProperty());

Note that this does an overwrite of, rather than an appending to, the TextArea.

To do an append, one must bind a ChangeListener to the message property instead.

like image 95
likejudo Avatar answered Sep 23 '22 11:09

likejudo