mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
TextField: fixed inactive and disabled background
This commit is contained in:
@@ -93,6 +93,16 @@ public abstract class FlatLaf
|
|||||||
public UIDefaults getDefaults() {
|
public UIDefaults getDefaults() {
|
||||||
UIDefaults defaults = getBase().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 );
|
initFonts( defaults );
|
||||||
loadDefaultsFromProperties( defaults );
|
loadDefaultsFromProperties( defaults );
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,11 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicTextFieldUI;
|
import javax.swing.plaf.basic.BasicTextFieldUI;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
@@ -67,19 +65,13 @@ public class FlatTextFieldUI
|
|||||||
|
|
||||||
float focusWidth = FlatUIUtils.getFocusWidth();
|
float focusWidth = FlatUIUtils.getFocusWidth();
|
||||||
|
|
||||||
g2.setColor( getBackground( c ) );
|
g2.setColor( c.getBackground() );
|
||||||
FlatUIUtils.fillRoundRectangle( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0 );
|
FlatUIUtils.fillRoundRectangle( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0 );
|
||||||
} finally {
|
} finally {
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color getBackground( JTextComponent c ) {
|
|
||||||
return c.isEditable() && c.isEnabled()
|
|
||||||
? c.getBackground()
|
|
||||||
: UIManager.getColor( "TextField.disabledBackground" );
|
|
||||||
}
|
|
||||||
|
|
||||||
//---- class Handler ------------------------------------------------------
|
//---- class Handler ------------------------------------------------------
|
||||||
|
|
||||||
private class Handler
|
private class Handler
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
*.inactiveForeground=@foreground
|
*.inactiveForeground=@foreground
|
||||||
*.selectionBackground=4B6EAF
|
*.selectionBackground=4B6EAF
|
||||||
*.selectionForeground=@foreground
|
*.selectionForeground=@foreground
|
||||||
|
*.disabledBackground=@background
|
||||||
*.disabledText=@disabledText
|
*.disabledText=@disabledText
|
||||||
|
|
||||||
|
|
||||||
@@ -92,4 +93,3 @@ Label.disabledForeground=@disabledText
|
|||||||
#---- TextField ----
|
#---- TextField ----
|
||||||
|
|
||||||
TextField.background=45494A
|
TextField.background=45494A
|
||||||
TextField.disabledBackground=@background
|
|
||||||
|
|||||||
@@ -28,10 +28,11 @@
|
|||||||
*.textBackground=cccccc
|
*.textBackground=cccccc
|
||||||
*.textForeground=@foreground
|
*.textForeground=@foreground
|
||||||
*.caretForeground=@foreground
|
*.caretForeground=@foreground
|
||||||
*.inactiveBackground=ffffff
|
*.inactiveBackground=@background
|
||||||
*.inactiveForeground=777777
|
*.inactiveForeground=777777
|
||||||
*.selectionBackground=4A6EB7
|
*.selectionBackground=4A6EB7
|
||||||
*.selectionForeground=ffffff
|
*.selectionForeground=ffffff
|
||||||
|
*.disabledBackground=@background
|
||||||
*.disabledText=@disabledText
|
*.disabledText=@disabledText
|
||||||
|
|
||||||
|
|
||||||
@@ -92,4 +93,3 @@ Label.disabledForeground=@disabledText
|
|||||||
#---- TextField ----
|
#---- TextField ----
|
||||||
|
|
||||||
TextField.background=ffffff
|
TextField.background=ffffff
|
||||||
TextField.disabledBackground=@background
|
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
|
|
||||||
*.background=ccffcc
|
*.background=ccffcc
|
||||||
*.foreground=ff0000
|
*.foreground=ff0000
|
||||||
|
*.inactiveBackground=f0f0f0
|
||||||
|
*.disabledBackground=e0e0e0
|
||||||
*.disabledText=000088
|
*.disabledText=000088
|
||||||
|
*.inactiveForeground=000088
|
||||||
|
|
||||||
|
|
||||||
#---- Button ----
|
#---- Button ----
|
||||||
@@ -72,4 +75,3 @@ Label.disabledForeground=000088
|
|||||||
#---- TextField ----
|
#---- TextField ----
|
||||||
|
|
||||||
TextField.background=ffffff
|
TextField.background=ffffff
|
||||||
TextField.disabledBackground=f2f2f2
|
|
||||||
|
|||||||
Reference in New Issue
Block a user