InternalFrame: fixed translucent internal frame menu bar background if TitlePane.unifiedBackground is true (issue #274)

This commit is contained in:
Karl Tauber
2021-03-23 15:08:01 +01:00
parent ce1a1487aa
commit f8ee8b27fb
2 changed files with 12 additions and 5 deletions

View File

@@ -16,6 +16,8 @@ FlatLaf Change Log
`frame.setVisible(true)`. (issue #277)
- Custom window decorations: Fixed NPE in `FlatTitlePane.findHorizontalGlue()`.
(issue #275)
- InternalFrame: Fixed translucent internal frame menu bar background if
`TitlePane.unifiedBackground` is `true`. (issue #274)
## 1.1

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui;
import java.awt.Graphics;
import java.awt.Window;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
@@ -86,7 +87,7 @@ public class FlatMenuBarUI
@Override
public void update( Graphics g, JComponent c ) {
// do not fill background if menubar is embedded into title pane
// paint background
if( isFillBackground( c ) ) {
g.setColor( c.getBackground() );
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
@@ -96,21 +97,25 @@ public class FlatMenuBarUI
}
protected boolean isFillBackground( JComponent c ) {
// paint background in opaque or having custom background color
// paint background if opaque or if having custom background color
if( c.isOpaque() || !(c.getBackground() instanceof UIResource) )
return true;
// paint background if menu bar is not the "main" menu bar
JRootPane rootPane = SwingUtilities.getRootPane( c );
if( rootPane == null || !(rootPane.getParent() instanceof Window) || rootPane.getJMenuBar() != c )
return true;
// do not paint background for unified title pane
if( unifiedBackground )
return false;
// paint background in full screen mode
JRootPane rootPane = SwingUtilities.getRootPane( c );
if( rootPane == null || FlatUIUtils.isFullScreen( rootPane ) )
if( FlatUIUtils.isFullScreen( rootPane ) )
return true;
// do not paint background if menu bar is embedded into title pane
return rootPane.getJMenuBar() != c || !FlatRootPaneUI.isMenuBarEmbedded( rootPane );
return !FlatRootPaneUI.isMenuBarEmbedded( rootPane );
}
//---- class TakeFocus ----------------------------------------------------