From 5a2c0672d43f2c0e10f4aa71f59024ed64f38911 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 23 Jul 2020 10:43:24 +0200 Subject: [PATCH] Window decorations: avoid possible endless restore/maximize in WindowStateListener in case of behavior changes in Java (issue #129) --- .../main/java/com/formdev/flatlaf/ui/FlatTitlePane.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 1d6295aa..0939494a 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 @@ -250,7 +250,11 @@ public class FlatTitlePane maximizeButton.setVisible( resizable && !maximized ); restoreButton.setVisible( resizable && maximized ); - if( maximized ) { + if( maximized && + rootPane.getClientProperty( "_flatlaf.maximizedBoundsUpToDate" ) == null ) + { + rootPane.putClientProperty( "_flatlaf.maximizedBoundsUpToDate", null ); + // In case that frame was maximized from custom code (e.g. when restoring // window state on application startup), then maximized bounds is not set // and the window would overlap Windows task bar. @@ -439,6 +443,9 @@ public class FlatTitlePane updateMaximizedBounds(); + // let our WindowStateListener know that the maximized bounds are up-to-date + rootPane.putClientProperty( "_flatlaf.maximizedBoundsUpToDate", true ); + // maximize window frame.setExtendedState( frame.getExtendedState() | Frame.MAXIMIZED_BOTH ); }