mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
Window decorations: support enabling/disabling unified title bar backgrounds at runtime without FlatLaf.updateUI()
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ class DemoFrame
|
||||
|
||||
private void unifiedTitleBar() {
|
||||
UIManager.put( "TitlePane.unifiedBackground", unifiedTitleBarMenuItem.isSelected() );
|
||||
FlatLaf.updateUI();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void underlineMenuSelection() {
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import javax.swing.*;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import net.miginfocom.swing.*;
|
||||
|
||||
/**
|
||||
@@ -112,7 +111,9 @@ public class FlatWindowDecorationsTest
|
||||
|
||||
private void unifiedBackgroundChanged() {
|
||||
UIManager.put( "TitlePane.unifiedBackground", unifiedBackgroundCheckBox.isSelected() );
|
||||
FlatLaf.updateUI();
|
||||
Window window = SwingUtilities.windowForComponent( this );
|
||||
if( window != null )
|
||||
window.repaint();
|
||||
}
|
||||
|
||||
private void menuBarChanged() {
|
||||
|
||||
Reference in New Issue
Block a user