diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java index 210bb87a..8785d280 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java @@ -93,6 +93,16 @@ public abstract class FlatLaf public UIDefaults getDefaults() { UIDefaults defaults = getBase().getDefaults(); + // initialize some defaults (for overriding) that are used in basic UI delegates, + // but are not set in MetalLookAndFeel or BasicLookAndFeel + Color control = defaults.getColor( "control" ); + defaults.put( "EditorPane.disabledBackground", control ); + defaults.put( "FormattedTextField.disabledBackground", control ); + defaults.put( "PasswordField.disabledBackground", control ); + defaults.put( "TextArea.disabledBackground", control ); + defaults.put( "TextField.disabledBackground", control ); + defaults.put( "TextPane.disabledBackground", control ); + initFonts( defaults ); loadDefaultsFromProperties( defaults ); diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java index 5f1cb5fb..3b336344 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java @@ -16,13 +16,11 @@ package com.formdev.flatlaf.ui; -import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import javax.swing.JComponent; -import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicTextFieldUI; import javax.swing.text.JTextComponent; @@ -67,19 +65,13 @@ public class FlatTextFieldUI float focusWidth = FlatUIUtils.getFocusWidth(); - g2.setColor( getBackground( c ) ); + g2.setColor( c.getBackground() ); FlatUIUtils.fillRoundRectangle( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0 ); } finally { g2.dispose(); } } - private Color getBackground( JTextComponent c ) { - return c.isEditable() && c.isEnabled() - ? c.getBackground() - : UIManager.getColor( "TextField.disabledBackground" ); - } - //---- class Handler ------------------------------------------------------ private class Handler diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties index 0ef778e5..3db70950 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -32,6 +32,7 @@ *.inactiveForeground=@foreground *.selectionBackground=4B6EAF *.selectionForeground=@foreground +*.disabledBackground=@background *.disabledText=@disabledText @@ -92,4 +93,3 @@ Label.disabledForeground=@disabledText #---- TextField ---- TextField.background=45494A -TextField.disabledBackground=@background diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties index d78fb7c0..2d41c172 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties @@ -28,10 +28,11 @@ *.textBackground=cccccc *.textForeground=@foreground *.caretForeground=@foreground -*.inactiveBackground=ffffff +*.inactiveBackground=@background *.inactiveForeground=777777 *.selectionBackground=4A6EB7 *.selectionForeground=ffffff +*.disabledBackground=@background *.disabledText=@disabledText @@ -92,4 +93,3 @@ Label.disabledForeground=@disabledText #---- TextField ---- TextField.background=ffffff -TextField.disabledBackground=@background diff --git a/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties b/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties index c890a8fc..0e1749c8 100644 --- a/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties +++ b/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties @@ -18,7 +18,10 @@ *.background=ccffcc *.foreground=ff0000 +*.inactiveBackground=f0f0f0 +*.disabledBackground=e0e0e0 *.disabledText=000088 +*.inactiveForeground=000088 #---- Button ---- @@ -72,4 +75,3 @@ Label.disabledForeground=000088 #---- TextField ---- TextField.background=ffffff -TextField.disabledBackground=f2f2f2