Changeset 14589 in josm for trunk/src


Ignore:
Timestamp:
2018-12-22T19:42:50+01:00 (6 years ago)
Author:
GerdP
Message:

#see #17040 implement Destroyable in ToggleDialog.TitleBar and use it in ToggleDialog.destroy()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r14470 r14589  
    470470        Config.getPref().removePreferenceChangeListener(this);
    471471        GuiHelper.destroyComponents(this, false);
     472        titleBar.destroy();
     473        titleBar = null;
     474        this.buttonActions.clear();
    472475    }
    473476
     
    501504     * The title bar displayed in docked mode
    502505     */
    503     protected class TitleBar extends JPanel {
     506    protected class TitleBar extends JPanel implements Destroyable {
    504507        /** the label which shows whether the toggle dialog is expanded or collapsed */
    505508        private final JLabel lblMinimized;
     
    511514        /** the contextual menu **/
    512515        private DialogPopupMenu popupMenu;
     516
     517        private MouseEventHandler mouseEventHandler;
    513518
    514519        @SuppressWarnings("unchecked")
     
    633638        public final void registerMouseListener() {
    634639            popupMenu = new DialogPopupMenu();
    635             addMouseListener(new MouseEventHandler());
     640            mouseEventHandler = new MouseEventHandler();
     641            addMouseListener(mouseEventHandler);
    636642        }
    637643
     
    656662                }
    657663            }
     664        }
     665
     666        @Override
     667        public void destroy() {
     668            removeMouseListener(mouseEventHandler);
     669            this.mouseEventHandler = null;
     670            this.popupMenu = null;
    658671        }
    659672    }
     
    754767     */
    755768    public void setTitle(String title) {
    756         titleBar.setTitle(title);
     769        if (titleBar != null) {
     770            titleBar.setTitle(title);
     771        }
    757772        if (detachedDialog != null) {
    758773            detachedDialog.setTitle(title);
Note: See TracChangeset for help on using the changeset viewer.