I'm embedding Multivalent in an application that requires me to place it within one tab of a Swing JTabbedPane. I would like to change the name of the tab to reflect the appropriate document each time a new document is loaded in the Multivalent tab. I'm fairly certain that I'll need to be able to catch semantic events in other Swing classes as well, so I'm looking for a general purpose way of trapping semantic events. I'm currently leaning in the direction of writing a behavior(s) that will trap semantic events and fire Swing ChangeEvents.
Any suggestions or discussion on the matter would be very much appreciated.
That sounds like a good plan. For this particular case, you can catch Document.MSG_OPENED and take the document title from that attribute in the Document class.
OK. Behavior written and (I believe) added to the system by including it in a hub. Now I'm left to wonder how I go about accessing the Behavior so that I can add ChangeEventListeners to it. Must I instantiate one using Behavior.getInstance() or is there a way to get a reference to a Behavior created because of it's inclusion in a hub?
Answering my own question...I'm now using getLayers() and getBehavior to attempt to locate the Behavior I created. The problem is that I don't see the behavior in any of the layers returned by getLayers(). Probably just a simple mistake, but some mention of common pitfalls when attempting to get a new behavior up and running would be helpful. Thanks.
You can search through the nested layers, use Layer.findBehavior() if you know the path, or create the behavior yourself with Behavior.getInstance() and then add it to the system. The last possibility has the advantage that you don't have to repackage Multivalent.jar.