Window decorations: support enabling/disabling unified title bar backgrounds at runtime without FlatLaf.updateUI()

This commit is contained in:
Karl Tauber
2021-03-30 01:34:34 +02:00
parent 7a2d0e7fcb
commit 1b5da0e1d1
4 changed files with 8 additions and 10 deletions

View File

@@ -53,8 +53,6 @@ import com.formdev.flatlaf.util.SystemInfo;
public class FlatMenuBarUI
extends BasicMenuBarUI
{
protected boolean unifiedBackground;
public static ComponentUI createUI( JComponent c ) {
return new FlatMenuBarUI();
}
@@ -69,8 +67,6 @@ public class FlatMenuBarUI
super.installDefaults();
LookAndFeel.installProperty( menuBar, "opaque", false );
unifiedBackground = UIManager.getBoolean( "TitlePane.unifiedBackground" );
}
@Override
@@ -107,7 +103,8 @@ public class FlatMenuBarUI
return true;
// do not paint background for unified title pane
if( unifiedBackground )
// (not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime)
if( UIManager.getBoolean( "TitlePane.unifiedBackground" ) )
return false;
// paint background in full screen mode

View File

@@ -105,7 +105,6 @@ public class FlatTitlePane
protected final Color embeddedForeground = UIManager.getColor( "TitlePane.embeddedForeground" );
protected final Color borderColor = UIManager.getColor( "TitlePane.borderColor" );
protected final boolean unifiedBackground = UIManager.getBoolean( "TitlePane.unifiedBackground" );
protected final Dimension iconSize = UIManager.getDimension( "TitlePane.iconSize" );
protected final int buttonMaximizedHeight = UIManager.getInt( "TitlePane.buttonMaximizedHeight" );
protected final boolean centerTitle = UIManager.getBoolean( "TitlePane.centerTitle" );
@@ -523,7 +522,8 @@ debug*/
@Override
protected void paintComponent( Graphics g ) {
if( !unifiedBackground ) {
// not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime
if( !UIManager.getBoolean( "TitlePane.unifiedBackground" ) ) {
g.setColor( getBackground() );
g.fillRect( 0, 0, getWidth(), getHeight() );
}