From d081b9e182177eee0489ddd421c77cbcde055014 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 7 Jun 2020 11:27:29 +0200 Subject: [PATCH] Window decorations: do not restore maximized bounds in method maximize() because when restoring an iconified frame by clicking on the Windows 10 taskbar the maximize() method is not invoked and the frame size becomes full screen size and overlaps taskbar --- .../com/formdev/flatlaf/ui/FlatTitlePane.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java index fd8ab46b..1addf9d6 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java @@ -366,12 +366,10 @@ class FlatTitlePane Frame frame = (Frame) window; + // set maximized bounds to avoid that maximized window overlaps Windows task bar if( !hasJBRCustomDecoration() ) { GraphicsConfiguration gc = window.getGraphicsConfiguration(); - // remember current maximized bounds - Rectangle oldMaximizedBounds = frame.getMaximizedBounds(); - // Screen bounds, which may be smaller than physical size on Java 9+. // E.g. if running a 3840x2160 screen at 200%, screenBounds.size is 1920x1080. // In Java 9+, each screen can have its own scale factor. @@ -415,20 +413,12 @@ class FlatTitlePane maximizedWidth - screenInsets.left - screenInsets.right, maximizedHeight - screenInsets.top - screenInsets.bottom ); - // temporary change maximized bounds + // change maximized bounds frame.setMaximizedBounds( maximizedBounds ); - - // maximize window - frame.setExtendedState( frame.getExtendedState() | Frame.MAXIMIZED_BOTH ); - - // restore old maximized bounds - frame.setMaximizedBounds( oldMaximizedBounds ); - } else { - // not necessary to set maximized bounds when running in JBR - - // maximize window - frame.setExtendedState( frame.getExtendedState() | Frame.MAXIMIZED_BOTH ); } + + // maximize window + frame.setExtendedState( frame.getExtendedState() | Frame.MAXIMIZED_BOTH ); } private void restore() {