Translating semantic events to swing events?

sgb
2005-06-13
2013-04-29
  • sgb
    sgb
    2005-06-13

    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.

    Thanks.

    -Shannon

     
    • Tom Phelps
      Tom Phelps
      2005-06-14

      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.

       
      • sgb
        sgb
        2005-06-14

        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?

         
    • sgb
      sgb
      2005-06-14

      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.

       
    • Tom Phelps
      Tom Phelps
      2005-06-15

      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.