mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
RootPane: give the root pane useful background, foreground and font
(fixes wrong background in title bar and menu bar when switching from Nimbus to FlatLaf)
This commit is contained in:
@@ -393,6 +393,7 @@ public abstract class FlatLaf
|
||||
"EditorPane.inactiveBackground",
|
||||
"FormattedTextField.disabledBackground",
|
||||
"PasswordField.disabledBackground",
|
||||
"RootPane.background",
|
||||
"Spinner.disabledBackground",
|
||||
"TextArea.disabledBackground",
|
||||
"TextArea.inactiveBackground",
|
||||
@@ -411,7 +412,8 @@ public abstract class FlatLaf
|
||||
"Spinner.disabledForeground",
|
||||
"ToggleButton.disabledText" );
|
||||
putDefaults( defaults, defaults.getColor( "textText" ),
|
||||
"DesktopIcon.foreground" );
|
||||
"DesktopIcon.foreground",
|
||||
"RootPane.foreground" );
|
||||
|
||||
initFonts( defaults );
|
||||
initIconColors( defaults, isDark() );
|
||||
@@ -541,6 +543,9 @@ public abstract class FlatLaf
|
||||
if( key instanceof String && (((String)key).endsWith( ".font" ) || ((String)key).endsWith( "Font" )) )
|
||||
defaults.put( key, activeFont );
|
||||
}
|
||||
|
||||
// add fonts that are not set in BasicLookAndFeel
|
||||
defaults.put( "RootPane.font", activeFont );
|
||||
}
|
||||
|
||||
private void initDefaultFont( UIDefaults defaults ) {
|
||||
|
||||
@@ -66,6 +66,9 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
*
|
||||
* <!-- FlatWindowResizer -->
|
||||
*
|
||||
* @uiDefault RootPane.font Font unused
|
||||
* @uiDefault RootPane.background Color
|
||||
* @uiDefault RootPane.foreground Color unused
|
||||
* @uiDefault RootPane.borderDragThickness int
|
||||
* @uiDefault RootPane.cornerDragWidth int
|
||||
* @uiDefault RootPane.honorFrameMinimumSizeOnResize boolean
|
||||
@@ -126,8 +129,23 @@ public class FlatRootPaneUI
|
||||
protected void installDefaults( JRootPane c ) {
|
||||
super.installDefaults( c );
|
||||
|
||||
// Give the root pane useful background, foreground and font.
|
||||
// Background is used for title bar and menu bar if native window decorations
|
||||
// and unified background are enabled.
|
||||
// Foreground and font are usually not used, but set for completeness.
|
||||
// Not using LookAndFeel.installColorsAndFont() here because it will not work
|
||||
// because the properties are null by default but inherit non-null values from parent.
|
||||
if( !c.isBackgroundSet() || c.getBackground() instanceof UIResource )
|
||||
c.setBackground( UIManager.getColor( "RootPane.background" ) );
|
||||
if( !c.isForegroundSet() || c.getForeground() instanceof UIResource )
|
||||
c.setForeground( UIManager.getColor( "RootPane.foreground" ) );
|
||||
if( !c.isFontSet() || c.getFont() instanceof UIResource )
|
||||
c.setFont( UIManager.getFont( "RootPane.font" ) );
|
||||
|
||||
// Update background color of JFrame or JDialog parent to avoid bad border
|
||||
// on HiDPI screens when switching from light to dark Laf.
|
||||
// Window background color is also used in native window decorations
|
||||
// to fill background when window is initially shown or when resizing window.
|
||||
// The background of JFrame is initialized in JFrame.frameInit() and
|
||||
// the background of JDialog in JDialog.dialogInit(),
|
||||
// but it was not updated when switching Laf.
|
||||
|
||||
@@ -474,9 +474,9 @@ public class FlatInspector
|
||||
if( c instanceof JComponent )
|
||||
appendRow( buf, "Border", toString( ((JComponent)c).getBorder(), classHierarchy ) );
|
||||
|
||||
appendRow( buf, "Background", toString( c.getBackground() ) );
|
||||
appendRow( buf, "Foreground", toString( c.getForeground() ) );
|
||||
appendRow( buf, "Font", toString( c.getFont() ) );
|
||||
appendRow( buf, "Background", toString( c.getBackground() ) + (c.isBackgroundSet() ? "" : " NOT SET") );
|
||||
appendRow( buf, "Foreground", toString( c.getForeground() ) + (c.isBackgroundSet() ? "" : " NOT SET") );
|
||||
appendRow( buf, "Font", toString( c.getFont() ) + (c.isFontSet() ? "" : " NOT SET") );
|
||||
|
||||
if( c instanceof JComponent ) {
|
||||
try {
|
||||
|
||||
@@ -818,6 +818,7 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F
|
||||
#---- RootPane ----
|
||||
|
||||
RootPane.activeBorderColor #4d5154 HSL 206 4 32 com.formdev.flatlaf.util.DerivedColor [UI] lighten(7% autoInverse)
|
||||
RootPane.background #3c3f41 HSL 204 4 25 javax.swing.plaf.ColorUIResource [UI]
|
||||
RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI]
|
||||
RootPane.borderDragThickness 5
|
||||
RootPane.cornerDragWidth 16
|
||||
@@ -830,6 +831,8 @@ RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object;
|
||||
[5] press
|
||||
[6] ctrl released ENTER
|
||||
[7] release
|
||||
RootPane.font [active] $defaultFont [UI]
|
||||
RootPane.foreground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI]
|
||||
RootPane.honorDialogMinimumSizeOnResize true
|
||||
RootPane.honorFrameMinimumSizeOnResize false
|
||||
RootPane.inactiveBorderColor #484c4e HSL 200 4 29 com.formdev.flatlaf.util.DerivedColor [UI] lighten(5% autoInverse)
|
||||
|
||||
@@ -823,6 +823,7 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F
|
||||
#---- RootPane ----
|
||||
|
||||
RootPane.activeBorderColor #737373 HSL 0 0 45 com.formdev.flatlaf.util.DerivedColor [UI] darken(50% autoInverse)
|
||||
RootPane.background #f2f2f2 HSL 0 0 95 javax.swing.plaf.ColorUIResource [UI]
|
||||
RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI]
|
||||
RootPane.borderDragThickness 5
|
||||
RootPane.cornerDragWidth 16
|
||||
@@ -835,6 +836,8 @@ RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object;
|
||||
[5] press
|
||||
[6] ctrl released ENTER
|
||||
[7] release
|
||||
RootPane.font [active] $defaultFont [UI]
|
||||
RootPane.foreground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI]
|
||||
RootPane.honorDialogMinimumSizeOnResize true
|
||||
RootPane.honorFrameMinimumSizeOnResize false
|
||||
RootPane.inactiveBorderColor #a6a6a6 HSL 0 0 65 com.formdev.flatlaf.util.DerivedColor [UI] darken(30% autoInverse)
|
||||
|
||||
@@ -833,6 +833,7 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F
|
||||
|
||||
#---- RootPane ----
|
||||
|
||||
RootPane.background #ccffcc HSL 120 100 90 javax.swing.plaf.ColorUIResource [UI]
|
||||
RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI]
|
||||
RootPane.borderDragThickness 5
|
||||
RootPane.cornerDragWidth 16
|
||||
@@ -845,6 +846,8 @@ RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object;
|
||||
[5] press
|
||||
[6] ctrl released ENTER
|
||||
[7] release
|
||||
RootPane.font [active] $defaultFont [UI]
|
||||
RootPane.foreground #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
RootPane.honorDialogMinimumSizeOnResize true
|
||||
RootPane.honorFrameMinimumSizeOnResize false
|
||||
RootPaneUI com.formdev.flatlaf.ui.FlatRootPaneUI
|
||||
|
||||
@@ -631,10 +631,13 @@ RangeSliderUI
|
||||
Resizable.resizeBorder
|
||||
RootPane.activeBorderColor
|
||||
RootPane.ancestorInputMap
|
||||
RootPane.background
|
||||
RootPane.border
|
||||
RootPane.borderDragThickness
|
||||
RootPane.cornerDragWidth
|
||||
RootPane.defaultButtonWindowKeyBindings
|
||||
RootPane.font
|
||||
RootPane.foreground
|
||||
RootPane.honorDialogMinimumSizeOnResize
|
||||
RootPane.honorFrameMinimumSizeOnResize
|
||||
RootPane.inactiveBorderColor
|
||||
|
||||
Reference in New Issue
Block a user