diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/MasterPassword.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/MasterPassword.java index 8d31651c..2231b055 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/MasterPassword.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/MasterPassword.java @@ -91,9 +91,9 @@ public final class MasterPassword { frame.setAlwaysOnTop( true ); frame.setVisible( true ); - frame.setExtendedState( Frame.NORMAL ); Platform.get().requestForeground(); frame.setAlwaysOnTop( false ); + frame.restore(); } ); } diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/util/platform/JDK9Platform.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/util/platform/JDK9Platform.java index 6bb0407b..da1716e8 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/util/platform/JDK9Platform.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/util/platform/JDK9Platform.java @@ -65,8 +65,10 @@ public class JDK9Platform implements IPlatform { @Override public boolean requestForeground() { - desktop.requestForeground( true ); - return true; + final boolean supported = desktop.isSupported(Desktop.Action.APP_REQUEST_FOREGROUND); + if (supported) + desktop.requestForeground( true ); + return supported; } @Override diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/MasterPasswordFrame.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/MasterPasswordFrame.java index 35b6b6ab..95eb9de2 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/MasterPasswordFrame.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/MasterPasswordFrame.java @@ -38,6 +38,17 @@ public class MasterPasswordFrame extends JFrame { userPanel.add( userContent.getUserToolbar(), BorderLayout.LINE_START ); userPanel.add( userContent.getSiteToolbar(), BorderLayout.LINE_END ); + restore(); + + final WindowHandler windowHandler = new WindowHandler(); + addWindowListener(windowHandler); + addWindowStateListener(windowHandler); + KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(windowHandler); + addComponentListener(new ResizeHandler()); + setDefaultCloseOperation(DISPOSE_ON_CLOSE); + } + + public void restore() { final MPGuiConfig config = MPGuiConfig.get(); if (config.getWindowSize() != null) { @@ -58,13 +69,6 @@ public class MasterPasswordFrame extends JFrame { if (config.getWindowMaximized()) setExtendedState(MAXIMIZED_BOTH); - - final WindowHandler windowHandler = new WindowHandler(); - addWindowListener(windowHandler); - addWindowStateListener(windowHandler); - KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(windowHandler); - addComponentListener(new ResizeHandler()); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); }