diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java index b41748cbb..cb3573f4b 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java @@ -51,7 +51,7 @@ public class ChatWindow { private Logger logger = Logger.getLogger(ChatWindow.class.getName()); - private MenusPanel menusPanel; + private final MenusPanel menusPanel; private MainFrame mainFrame; @@ -149,6 +149,7 @@ public void dispose() try { GuiActivator.getUIService().removePluginComponentListener(this); + menusPanel.dispose(); } finally { diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/MenusPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/MenusPanel.java index 270a4d114..5d6651a59 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/MenusPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/MenusPanel.java @@ -21,15 +21,16 @@ * window. * * @author Yana Stamcheva + * @author Lubomir Marinov */ public class MenusPanel extends JPanel { - private MessageWindowMenuBar menuBar; + private final MessageWindowMenuBar menuBar; - private MainToolBar mainToolBar; + private final MainToolBar mainToolBar; - private ChatWindow parentWindow; + private final ChatWindow parentWindow; /** * Creates an instance and constructs the MenusPanel. @@ -59,6 +60,17 @@ public MenusPanel(ChatWindow parentWindow) this.add(mainToolBar, BorderLayout.CENTER); } + /** + * Runs clean-up for associated resources which need explicit disposal (e.g. + * listeners keeping this instance alive because they were added to the + * model which operationally outlives this instance). + */ + public void dispose() + { + mainToolBar.dispose(); + menuBar.dispose(); + } + /** * Adds a new toolbar to this MenusPanel. * diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java index ba2501172..e8643f387 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java @@ -24,18 +24,14 @@ * The HelpMenu is a menu in the main application menu bar. * * @author Yana Stamcheva + * @author Lubomir Marinov */ public class HelpMenu extends SIPCommMenu implements ActionListener, PluginComponentListener { - - private Logger logger = Logger.getLogger(HelpMenu.class.getName()); - - private I18NString aboutString = Messages.getI18NString("about"); - - private ChatWindow chatWindow; + private final Logger logger = Logger.getLogger(HelpMenu.class.getName()); /** * Creates an instance of HelpMenu. @@ -45,8 +41,6 @@ public HelpMenu(ChatWindow chatWindow) { super(Messages.getI18NString("help").getText()); - this.chatWindow = chatWindow; - this.setForeground(new Color( GuiActivator.getResources().getColor("chatMenuForeground"))); @@ -55,6 +49,22 @@ public HelpMenu(ChatWindow chatWindow) { this.initPluginComponents(); } + /** + * Runs clean-up for associated resources which need explicit disposal (e.g. + * listeners keeping this instance alive because they were added to the + * model which operationally outlives this instance). + */ + public void dispose() + { + GuiActivator.getUIService().removePluginComponentListener(this); + + /* + * Let go of all Components contributed by PluginComponents because the + * latter will still live in the contribution store. + */ + removeAll(); + } + /** * Initialize plugin components already registered for this container. */ diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/MessageWindowMenuBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/MessageWindowMenuBar.java index 1ef313f5f..8b6b845fb 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/MessageWindowMenuBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/MessageWindowMenuBar.java @@ -26,20 +26,21 @@ * all menus are added. * * @author Yana Stamcheva + * @author Lubomir Marinov */ public class MessageWindowMenuBar extends JMenuBar implements PluginComponentListener { - private Logger logger = Logger.getLogger(MessageWindowMenuBar.class); + private final Logger logger = Logger.getLogger(MessageWindowMenuBar.class); private FileMenu fileMenu; private EditMenu editMenu; - private HelpMenu helpMenu; + private final HelpMenu helpMenu; - private ChatWindow parentWindow; + private final ChatWindow parentWindow; /** * Creates an instance of MessageWindowMenuBar. @@ -62,6 +63,17 @@ public MessageWindowMenuBar(ChatWindow parentWindow) this.initPluginComponents(); } + /** + * Runs clean-up for associated resources which need explicit disposal (e.g. + * listeners keeping this instance alive because they were added to the + * model which operationally outlives this instance). + */ + public void dispose() + { + GuiActivator.getUIService().removePluginComponentListener(this); + helpMenu.dispose(); + } + /** * Initializes the menu bar, by adding all contained menus. */ diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index f1b7ca6a8..c2c2abdaf 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -37,6 +37,7 @@ * rollover behaviour to differentiates them from normal buttons. * * @author Yana Stamcheva + * @author Lubomir Marinov */ public class MainToolBar extends SIPCommToolBar @@ -262,6 +263,16 @@ public void chatChanged(ChatPanel panel) }); } + /** + * Runs clean-up for associated resources which need explicit disposal (e.g. + * listeners keeping this instance alive because they were added to the + * model which operationally outlives this instance). + */ + public void dispose() + { + GuiActivator.getUIService().removePluginComponentListener(this); + } + /** * Handles the ActionEvent, when one of the toolbar buttons is * clicked.