From 6909bb4b0378086a2d84e5fa0bb8d54ec4737bb4 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Wed, 31 Mar 2021 20:56:17 +0200 Subject: [PATCH] Native window decorations: removed superfluous pixel-line at top of screen when window is maximized (issue #296) --- CHANGELOG.md | 2 ++ .../java/com/formdev/flatlaf/ui/FlatTitlePane.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b649dae..a14f29bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ FlatLaf Change Log #### Fixed bugs - Fixed crash when running in Webswing. (issue #290) +- Native window decorations: Removed superfluous pixel-line at top of screen + when window is maximized. (issue #296) ## 1.1.1 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 845c1aa0..05a0cb1c 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 @@ -803,7 +803,7 @@ debug*/ } else if( borderColor != null && (rootPane.getJMenuBar() == null || !rootPane.getJMenuBar().isVisible()) ) insets.bottom += UIScale.scale( 1 ); - if( hasNativeCustomDecoration() ) + if( hasNativeCustomDecoration() && !isWindowMaximized( c ) ) insets = FlatUIUtils.addInsets( insets, WindowTopBorder.getInstance().getBorderInsets() ); return insets; @@ -822,7 +822,7 @@ debug*/ FlatUIUtils.paintFilledRectangle( g, borderColor, x, y + height - lineHeight, width, lineHeight ); } - if( hasNativeCustomDecoration() ) + if( hasNativeCustomDecoration() && !isWindowMaximized( c ) ) WindowTopBorder.getInstance().paintBorder( c, g, x, y, width, height ); } @@ -830,6 +830,12 @@ debug*/ JMenuBar menuBar = rootPane.getJMenuBar(); return hasVisibleEmbeddedMenuBar( menuBar ) ? menuBar.getBorder() : null; } + + protected boolean isWindowMaximized( Component c ) { + return window instanceof Frame + ? (((Frame)window).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 + : false; + } } //---- class FlatTitleLabelUI ---------------------------------------------