swingx
  1. swingx
  2. SWINGX-73

Add event source registration methods to JXStatusBar

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 0.9.0
    • Fix Version/s: 0.9.0
    • Component/s: Misc Component
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      73

      Description

      When a component is added to a JXRootPane, JXRootPane searches through the
      component tree rooted at the added component looking for MessageSources and
      ProgressSources. The method that does this is registerStatusBar(). If the
      component added to JXRootPane has not been assigned its children yet, then the
      search obviously won't find these sources when they are added later. That's
      fine. I can register and deregister my components myself.
      JXRootPane.registerStatusBar() and JXRootPane.unregisterStatusBar() would be
      handy for this purpose but both are private.

      It'd be cleaner if JXStatusBar provided a registerWithComponent(Component) and a
      unregisterFromComponent(Component) method (both public!). The functionality of
      these methods would be the same as the methods in JXRootPane. Here's the code:

      /**

      • Register this <code>JXStatusBar</code> with all
      • <code>MessageSource</code>s and <code>ProgressSource</code>s in the
      • component tree rooted at <code>comp</code>.
        *
      • @param comp root of the <code>Component</code> tree containing event sources
        */
        public void registerWithComponent(Component comp) {
        if (comp == null) { return; }

        if (comp instanceof MessageSource) { MessageSource source = (MessageSource) comp; source.addMessageListener(this); }
        if (comp instanceof ProgressSource) { ProgressSource source = (ProgressSource) comp; source.addProgressListener(this); }
        if (comp instanceof Container) {
        Component[] comps = ((Container) comp).getComponents();
        for (int i = 0; i < comps.length; i++) { registerWithComponent(comps[i]); }
        }
        }

        /**
        * Unregister this <code>JXStatusBar</code> from all
        * <code>MessageSource</code>s and <code>ProgressSource</code>s in the
        * component tree rooted at <code>comp</code>.
        *
        * @param comp root of the <code>Component</code> tree containing event sources
        */
        public void unregisterFromComponent(Component comp) {
        if (comp == null) { return; }

      if (comp instanceof MessageSource)

      { MessageSource source = (MessageSource) comp; source.removeMessageListener(this); }

      if (comp instanceof ProgressSource)

      { ProgressSource source = (ProgressSource) comp; source.removeProgressListener(this); }

      if (comp instanceof Container) {
      Component[] comps = ((Container) comp).getComponents();
      for (int i = 0; i < comps.length; i++)

      { unregisterFromComponent(comps[i]); }

      }
      }

        Activity

        Hide
        kleopatra added a comment -

        cleanup: subcomponent

        Show
        kleopatra added a comment - cleanup: subcomponent
        Hide
        rbair added a comment -

        This is outside the scope of JXRootPane and JXStatusBar after the JXStatusBar refactoring.

        Show
        rbair added a comment - This is outside the scope of JXRootPane and JXStatusBar after the JXStatusBar refactoring.

          People

          • Assignee:
            swingx-issues
            Reporter:
            neilweber
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: