InternalFrame: fill background to avoid that parent may shine through internal frame if it contains non-opaque components (better fix for issue #274)

This commit is contained in:
Karl Tauber
2021-12-15 00:27:20 +01:00
parent 8e107647bd
commit 5fd5b1206e
3 changed files with 33 additions and 0 deletions

View File

@@ -90,6 +90,12 @@ FlatLaf Change Log
- New "column control" icon for `JXTable` that scales and uses antialiasing. - New "column control" icon for `JXTable` that scales and uses antialiasing.
(issue #434) (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 ## 1.6.5
#### Fixed bugs #### Fixed bugs

View File

@@ -213,6 +213,13 @@ public class FlatInternalFrameTitlePane
case "componentOrientation": case "componentOrientation":
applyComponentOrientation( frame.getComponentOrientation() ); applyComponentOrientation( frame.getComponentOrientation() );
break; 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 ); super.propertyChange( e );

View File

@@ -179,6 +179,26 @@ public class FlatInternalFrameUI
return FlatStylingSupport.getAnnotatedStyleableInfos( this, frame.getBorder() ); 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 -------------------------------------- //---- class FlatInternalFrameBorder --------------------------------------
public static class FlatInternalFrameBorder public static class FlatInternalFrameBorder