mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
InternalFrame: fixed translucent internal frame menu bar background if TitlePane.unifiedBackground is true (issue #274)
This commit is contained in:
@@ -16,6 +16,8 @@ FlatLaf Change Log
|
|||||||
`frame.setVisible(true)`. (issue #277)
|
`frame.setVisible(true)`. (issue #277)
|
||||||
- Custom window decorations: Fixed NPE in `FlatTitlePane.findHorizontalGlue()`.
|
- Custom window decorations: Fixed NPE in `FlatTitlePane.findHorizontalGlue()`.
|
||||||
(issue #275)
|
(issue #275)
|
||||||
|
- InternalFrame: Fixed translucent internal frame menu bar background if
|
||||||
|
`TitlePane.unifiedBackground` is `true`. (issue #274)
|
||||||
|
|
||||||
|
|
||||||
## 1.1
|
## 1.1
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Window;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.ActionMap;
|
import javax.swing.ActionMap;
|
||||||
@@ -86,7 +87,7 @@ public class FlatMenuBarUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update( Graphics g, JComponent c ) {
|
public void update( Graphics g, JComponent c ) {
|
||||||
// do not fill background if menubar is embedded into title pane
|
// paint background
|
||||||
if( isFillBackground( c ) ) {
|
if( isFillBackground( c ) ) {
|
||||||
g.setColor( c.getBackground() );
|
g.setColor( c.getBackground() );
|
||||||
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
|
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
|
||||||
@@ -96,21 +97,25 @@ public class FlatMenuBarUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isFillBackground( JComponent c ) {
|
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) )
|
if( c.isOpaque() || !(c.getBackground() instanceof UIResource) )
|
||||||
return true;
|
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
|
// do not paint background for unified title pane
|
||||||
if( unifiedBackground )
|
if( unifiedBackground )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// paint background in full screen mode
|
// paint background in full screen mode
|
||||||
JRootPane rootPane = SwingUtilities.getRootPane( c );
|
if( FlatUIUtils.isFullScreen( rootPane ) )
|
||||||
if( rootPane == null || FlatUIUtils.isFullScreen( rootPane ) )
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// do not paint background if menu bar is embedded into title pane
|
// 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 ----------------------------------------------------
|
//---- class TakeFocus ----------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user