This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Here's the scenario: A "start" button is clicked which sets up a Service/Task which includes I/O with a device. A changeListener is started, and the "start" button handler ends. Eventually, the changeListener detects a "change" and does its thing with the I/O device. NOW my question: How do I "notify" the user that the "change" (event) has occurred? "Update message" doesn't do anything since the "start" button routine has ended. I know I'm missing something fundamental here, but I'm baffled. (This is my first foray into the Service/Task business...) (The code in all other respects works great.) Thanks! L (Here is the boiled-down code.)
This is an interesting scenario. The usual examples for tasks have a blocking task happening within the Task and so updation of GUI can be done. But, in this case, you just register a callback handler. Actually, in this case, you may not need the task to just install the listener.
And from within the listener, You can wrap the UI update call in Platform.runLater()
SCJP 1.4, OCMJEA/SCEA 5.0.
Joined: Feb 19, 2012
Ranga, thanks for the reply. I decided to keep the service/task since the setup part (which I omitted to save space) may hang/block. However, I solved the "communication" problem by BINDING the text in a textArea with the messageProperty in the Task! Perhaps this has the same effect as you were suggesting (by different means)?? Anyway, it all appears to work now, and I'm off struggling with the Android client code... Thanks again! L