diff --git a/CHANGELOG.md b/CHANGELOG.md index 84086e32..c80ef6f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,6 +92,8 @@ FlatLaf Change Log #### Fixed bugs +- MenuBar: Do not fill background if non-opaque and having custom background + color. (issue #409) - InternalFrame: Fill background to avoid that parent may shine through internal frame if it contains non-opaque components. (better fix for issue #274) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java index f1d9e038..1f4b217e 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java @@ -180,11 +180,15 @@ public class FlatMenuBarUI protected Color getBackground( JComponent c ) { Color background = c.getBackground(); - // paint background if opaque or if having custom background color - if( c.isOpaque() || !(background instanceof UIResource) ) + // paint background if opaque + if( c.isOpaque() ) return background; - // paint background if menu bar is not the "main" menu bar + // do not paint background if non-opaque and having custom background color + if( !(background instanceof UIResource) ) + return null; + + // paint background if menu bar is not the "main" menu bar (e.g. in internal frame) JRootPane rootPane = SwingUtilities.getRootPane( c ); if( rootPane == null || !(rootPane.getParent() instanceof Window) || rootPane.getJMenuBar() != c ) return background;