diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b91df39..84086e32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,12 @@ FlatLaf Change Log - New "column control" icon for `JXTable` that scales and uses antialiasing. (issue #434) +#### Fixed bugs + +- InternalFrame: Fill background to avoid that parent may shine through internal + frame if it contains non-opaque components. (better fix for issue #274) + + ## 1.6.5 #### Fixed bugs diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java index a8be1e2f..500936a2 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java @@ -213,6 +213,13 @@ public class FlatInternalFrameTitlePane case "componentOrientation": applyComponentOrientation( frame.getComponentOrientation() ); break; + + case "opaque": + // Do not invoke super.propertyChange() here because it always + // invokes repaint(), which would cause endless repainting. + // The opaque flag is temporary changed in FlatUIUtils.hasOpaqueBeenExplicitlySet(), + // invoked from FlatInternalFrameUI.update(). + return; } super.propertyChange( e ); diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java index 9ca4f315..2db28a82 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java @@ -179,6 +179,26 @@ public class FlatInternalFrameUI return FlatStylingSupport.getAnnotatedStyleableInfos( this, frame.getBorder() ); } + @Override + public void update( Graphics g, JComponent c ) { + // The internal frame actually should be opaque and fill its background, + // but it must be non-opaque to allow translucent resize handles (outside of visual bounds). + // To avoid that parent may shine through internal frame (e.g. if menu bar is non-opaque), + // fill background excluding insets (translucent resize handles), + // but only if opaque was not set explicitly by application to false. + // If applications has set internal frame opacity to false, do not fill background (for compatibility). + if( !c.isOpaque() && !FlatUIUtils.hasOpaqueBeenExplicitlySet( c ) ) { + Insets insets = c.getInsets(); + + g.setColor( c.getBackground() ); + g.fillRect( insets.left, insets.top, + c.getWidth() - insets.left - insets.right, + c.getHeight() - insets.top - insets.bottom ); + } + + super.update( g, c ); + } + //---- class FlatInternalFrameBorder -------------------------------------- public static class FlatInternalFrameBorder