diff --git a/CHANGELOG.md b/CHANGELOG.md index 519a64ab..2e0c9c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ FlatLaf Change Log ## Unreleased - Hide focus indicator when window is inactive. -- Improved/fixed window border color in dark themes in custom window - decorations. +- Custom window decorations: Improved/fixed window border color in dark themes. +- Custom window decorations: Hide window border if window is maximized. ## 0.37 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java index 0506390b..fec59e04 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java @@ -20,6 +20,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; @@ -334,8 +335,21 @@ public class FlatRootPaneUI super( 1, 1, 1, 1 ); } + @Override + public Insets getBorderInsets( Component c, Insets insets ) { + if( isWindowMaximized( c ) ) { + // hide border if window is maximized + insets.top = insets.left = insets.bottom = insets.right = 0; + return insets; + } else + return super.getBorderInsets( c, insets ); + } + @Override public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) { + if( isWindowMaximized( c ) ) + return; + Container parent = c.getParent(); boolean active = parent instanceof Window ? ((Window)parent).isActive() : false; @@ -346,5 +360,12 @@ public class FlatRootPaneUI private void paintImpl( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) { g.drawRect( x, y, width - 1, height - 1 ); } + + protected boolean isWindowMaximized( Component c ) { + Container parent = c.getParent(); + return parent instanceof Frame + ? (((Frame)parent).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 + : false; + } } }