This content has been marked as final. Show 5 replies
Sorry for the delay. I had to create a Google Code project to host the example:
The source code for the message bus API is here:
It essentially allows callers to subscribe to "message topics", which are simply Java types. Any time an instance of a given type is sent, subscribed listeners are notified. Any Java type can be used including enums, which provide a nice, type-safe way to define messages.
An example demonstrating how to use the API is here:
The main application window presents a tab pane containing 3 identical tabs. Each tab's controller subscribes to a message of type com.oracle.sjmb.test.Message. Entering text in the text field and pressing the "Send Message" button sends a new message, causing the other two tabs to update the contents of their own text fields to match.
The example application consists of the following files:
Message.java - the message class
MessageBusTest.java - the main JavaFX application class
message_bus_test.fxml - FXML document containing the main scene
tab.fxml - FXML document containing tab pane content
TabController.java - tab content controller
Javadoc and binaries are available here:
Please note that this is an example only and is not an official part of any Oracle product. Let me know if you have any questions.
It seems that I need to adjust my way of thinking and ignore what I have learned about how c# handles 'events'Not necessarily. JavaFX also has a concept of "events", which extend the javafx.event.Event class. However, registering for these events requires that the listener be aware of the event source, which is not always practical. A message bus just allows application components (such as view controllers) to communicate with each other in a more decoupled fashion.
 Theoretically, an Event subclass could be used as the message type, though I have not tried this.
Edited by: Greg Brown on Jul 31, 2012 5:39 AM