diff options
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui/main/MainFrame.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/main/MainFrame.java | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java index a8ee80a..b450efe 100644 --- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java @@ -334,13 +334,9 @@ public class MainFrame */ private void init() { - setDefaultCloseOperation( - GuiActivator.getUIService().getExitOnMainWindowClose() - ? JFrame.DISPOSE_ON_CLOSE - : JFrame.HIDE_ON_CLOSE); - + // at startup, we cannot hide yet + updateCloseAction(false); registerKeyActions(); - JComponent northPanel = createTopComponent(); this.setJMenuBar(menu); @@ -394,6 +390,30 @@ public class MainFrame } } + /** + * If hiding is possible and the option to minimize is not selected, the + * application gets hidden on clicking 'X'. + * + * @param true if hiding is possible, i.e. a tray icon is loaded + */ + public void updateCloseAction(boolean canHide) + { + if (ConfigurationUtils.isMinimizeInsteadOfHide()) + { + logger.info("Updating close action: DO_NOTHING_ON_CLOSE"); + setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + } + else + { + logger.info("Updating close action: " + (canHide + ? "HIDE_ON_CLOSE" + : "DISPOSE_ON_CLOSE")); + setDefaultCloseOperation(canHide + ? JFrame.HIDE_ON_CLOSE + : JFrame.DISPOSE_ON_CLOSE); + } + } + private Component createButtonPanel() { boolean isCallButtonEnabled = false; @@ -1885,7 +1905,8 @@ public class MainFrame */ protected void windowClosed(WindowEvent event) { - if(GuiActivator.getUIService().getExitOnMainWindowClose()) + if(getDefaultCloseOperation() == JFrame.EXIT_ON_CLOSE || + getDefaultCloseOperation() == JFrame.DISPOSE_ON_CLOSE) { try { @@ -1919,9 +1940,17 @@ public class MainFrame // On Mac systems the application is not quited on window close, so we // don't need to warn the user. - if (!GuiActivator.getUIService().getExitOnMainWindowClose() - && !OSUtils.IS_MAC) + if (OSUtils.IS_MAC) { + return; + } + + switch (getDefaultCloseOperation()) + { + case JFrame.EXIT_ON_CLOSE: + case JFrame.DISPOSE_ON_CLOSE: + return; + case JFrame.HIDE_ON_CLOSE: SwingUtilities.invokeLater(new Runnable() { public void run() @@ -1940,8 +1969,11 @@ public class MainFrame } } }); - ConfigurationUtils.setApplicationVisible(false); + break; + case JFrame.DO_NOTHING_ON_CLOSE: + this.minimize(); + break; } } |