mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -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
|
public class FlatMenuBarUI
|
||||||
extends BasicMenuBarUI
|
extends BasicMenuBarUI
|
||||||
{
|
{
|
||||||
protected boolean unifiedBackground;
|
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatMenuBarUI();
|
return new FlatMenuBarUI();
|
||||||
}
|
}
|
||||||
@@ -69,8 +67,6 @@ public class FlatMenuBarUI
|
|||||||
super.installDefaults();
|
super.installDefaults();
|
||||||
|
|
||||||
LookAndFeel.installProperty( menuBar, "opaque", false );
|
LookAndFeel.installProperty( menuBar, "opaque", false );
|
||||||
|
|
||||||
unifiedBackground = UIManager.getBoolean( "TitlePane.unifiedBackground" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,7 +103,8 @@ public class FlatMenuBarUI
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// do not paint background for unified title pane
|
// 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;
|
return false;
|
||||||
|
|
||||||
// paint background in full screen mode
|
// paint background in full screen mode
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ public class FlatTitlePane
|
|||||||
protected final Color embeddedForeground = UIManager.getColor( "TitlePane.embeddedForeground" );
|
protected final Color embeddedForeground = UIManager.getColor( "TitlePane.embeddedForeground" );
|
||||||
protected final Color borderColor = UIManager.getColor( "TitlePane.borderColor" );
|
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 Dimension iconSize = UIManager.getDimension( "TitlePane.iconSize" );
|
||||||
protected final int buttonMaximizedHeight = UIManager.getInt( "TitlePane.buttonMaximizedHeight" );
|
protected final int buttonMaximizedHeight = UIManager.getInt( "TitlePane.buttonMaximizedHeight" );
|
||||||
protected final boolean centerTitle = UIManager.getBoolean( "TitlePane.centerTitle" );
|
protected final boolean centerTitle = UIManager.getBoolean( "TitlePane.centerTitle" );
|
||||||
@@ -523,7 +522,8 @@ debug*/
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent( Graphics g ) {
|
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.setColor( getBackground() );
|
||||||
g.fillRect( 0, 0, getWidth(), getHeight() );
|
g.fillRect( 0, 0, getWidth(), getHeight() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ class DemoFrame
|
|||||||
|
|
||||||
private void unifiedTitleBar() {
|
private void unifiedTitleBar() {
|
||||||
UIManager.put( "TitlePane.unifiedBackground", unifiedTitleBarMenuItem.isSelected() );
|
UIManager.put( "TitlePane.unifiedBackground", unifiedTitleBarMenuItem.isSelected() );
|
||||||
FlatLaf.updateUI();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void underlineMenuSelection() {
|
private void underlineMenuSelection() {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
import com.formdev.flatlaf.FlatLaf;
|
|
||||||
import net.miginfocom.swing.*;
|
import net.miginfocom.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,7 +111,9 @@ public class FlatWindowDecorationsTest
|
|||||||
|
|
||||||
private void unifiedBackgroundChanged() {
|
private void unifiedBackgroundChanged() {
|
||||||
UIManager.put( "TitlePane.unifiedBackground", unifiedBackgroundCheckBox.isSelected() );
|
UIManager.put( "TitlePane.unifiedBackground", unifiedBackgroundCheckBox.isSelected() );
|
||||||
FlatLaf.updateUI();
|
Window window = SwingUtilities.windowForComponent( this );
|
||||||
|
if( window != null )
|
||||||
|
window.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void menuBarChanged() {
|
private void menuBarChanged() {
|
||||||
|
|||||||
Reference in New Issue
Block a user