mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-09 16:25:10 +03:00
PasswordField: get echoChar from .properties files and no longer hard code it on macOS
This commit is contained in:
@@ -221,7 +221,7 @@ class UIDefaultsLoader
|
|||||||
return resolveValue( properties, newValue );
|
return resolveValue( properties, newValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ValueType { UNKNOWN, STRING, INTEGER, FLOAT, BORDER, ICON, INSETS, DIMENSION, COLOR,
|
private enum ValueType { UNKNOWN, STRING, CHARACTER, INTEGER, FLOAT, BORDER, ICON, INSETS, DIMENSION, COLOR,
|
||||||
SCALEDINTEGER, SCALEDFLOAT, SCALEDINSETS, SCALEDDIMENSION, INSTANCE, CLASS }
|
SCALEDINTEGER, SCALEDFLOAT, SCALEDINSETS, SCALEDDIMENSION, INSTANCE, CLASS }
|
||||||
|
|
||||||
static Object parseValue( String key, String value ) {
|
static Object parseValue( String key, String value ) {
|
||||||
@@ -285,6 +285,8 @@ class UIDefaultsLoader
|
|||||||
valueType = ValueType.DIMENSION;
|
valueType = ValueType.DIMENSION;
|
||||||
else if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
else if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
||||||
valueType = ValueType.INTEGER;
|
valueType = ValueType.INTEGER;
|
||||||
|
else if( key.endsWith( "Char" ) )
|
||||||
|
valueType = ValueType.CHARACTER;
|
||||||
else if( key.endsWith( "UI" ) )
|
else if( key.endsWith( "UI" ) )
|
||||||
valueType = ValueType.STRING;
|
valueType = ValueType.STRING;
|
||||||
}
|
}
|
||||||
@@ -292,6 +294,7 @@ class UIDefaultsLoader
|
|||||||
// parse value
|
// parse value
|
||||||
switch( valueType ) {
|
switch( valueType ) {
|
||||||
case STRING: return value;
|
case STRING: return value;
|
||||||
|
case CHARACTER: return parseCharacter( value );
|
||||||
case INTEGER: return parseInteger( value, true );
|
case INTEGER: return parseInteger( value, true );
|
||||||
case FLOAT: return parseFloat( value, true );
|
case FLOAT: return parseFloat( value, true );
|
||||||
case BORDER: return parseBorder( value, resolver, addonClassLoaders );
|
case BORDER: return parseBorder( value, resolver, addonClassLoaders );
|
||||||
@@ -599,6 +602,12 @@ class UIDefaultsLoader
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Character parseCharacter( String value ) {
|
||||||
|
if( value.length() != 1 )
|
||||||
|
throw new IllegalArgumentException( "invalid character '" + value + "'" );
|
||||||
|
return value.charAt( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
private static Integer parseInteger( String value, int min, int max ) {
|
private static Integer parseInteger( String value, int min, int max ) {
|
||||||
Integer integer = parseInteger( value, true );
|
Integer integer = parseInteger( value, true );
|
||||||
if( integer.intValue() < min || integer.intValue() > max )
|
if( integer.intValue() < min || integer.intValue() > max )
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import javax.swing.plaf.ComponentUI;
|
|||||||
import javax.swing.plaf.basic.BasicPasswordFieldUI;
|
import javax.swing.plaf.basic.BasicPasswordFieldUI;
|
||||||
import javax.swing.text.Caret;
|
import javax.swing.text.Caret;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
import com.formdev.flatlaf.util.SystemInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JPasswordField}.
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JPasswordField}.
|
||||||
@@ -78,10 +77,6 @@ public class FlatPasswordFieldUI
|
|||||||
protected void installDefaults() {
|
protected void installDefaults() {
|
||||||
super.installDefaults();
|
super.installDefaults();
|
||||||
|
|
||||||
// use other echoChar on Mac because the default is too large in SF font
|
|
||||||
if( SystemInfo.IS_MAC )
|
|
||||||
LookAndFeel.installProperty( getComponent(), "echoChar", '\u2022' );
|
|
||||||
|
|
||||||
String prefix = getPropertyPrefix();
|
String prefix = getPropertyPrefix();
|
||||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ PasswordField.border=com.formdev.flatlaf.ui.FlatBorder
|
|||||||
PasswordField.margin=@textComponentMargin
|
PasswordField.margin=@textComponentMargin
|
||||||
PasswordField.background=@textComponentBackground
|
PasswordField.background=@textComponentBackground
|
||||||
PasswordField.placeholderForeground=@disabledText
|
PasswordField.placeholderForeground=@disabledText
|
||||||
|
PasswordField.echoChar=\u2022
|
||||||
|
|
||||||
|
|
||||||
#---- PopupMenu ----
|
#---- PopupMenu ----
|
||||||
|
|||||||
@@ -1034,7 +1034,7 @@ PasswordField.capsLockIconColor #64000000 javax.swing.plaf.ColorUIResource [U
|
|||||||
PasswordField.caretBlinkRate 500
|
PasswordField.caretBlinkRate 500
|
||||||
PasswordField.caretForeground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
PasswordField.caretForeground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||||
PasswordField.disabledBackground #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
PasswordField.disabledBackground #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
||||||
PasswordField.echoChar '\u25cf'
|
PasswordField.echoChar '\u2022'
|
||||||
PasswordField.focusInputMap [lazy] 66 javax.swing.plaf.InputMapUIResource [UI]
|
PasswordField.focusInputMap [lazy] 66 javax.swing.plaf.InputMapUIResource [UI]
|
||||||
alt pressed BACK_SPACE delete-previous-word
|
alt pressed BACK_SPACE delete-previous-word
|
||||||
alt pressed DELETE delete-next-word
|
alt pressed DELETE delete-next-word
|
||||||
|
|||||||
@@ -1036,7 +1036,7 @@ PasswordField.capsLockIconColor #64000000 javax.swing.plaf.ColorUIResource [U
|
|||||||
PasswordField.caretBlinkRate 500
|
PasswordField.caretBlinkRate 500
|
||||||
PasswordField.caretForeground #000000 javax.swing.plaf.ColorUIResource [UI]
|
PasswordField.caretForeground #000000 javax.swing.plaf.ColorUIResource [UI]
|
||||||
PasswordField.disabledBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
PasswordField.disabledBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
||||||
PasswordField.echoChar '\u25cf'
|
PasswordField.echoChar '\u2022'
|
||||||
PasswordField.focusInputMap [lazy] 66 javax.swing.plaf.InputMapUIResource [UI]
|
PasswordField.focusInputMap [lazy] 66 javax.swing.plaf.InputMapUIResource [UI]
|
||||||
alt pressed BACK_SPACE delete-previous-word
|
alt pressed BACK_SPACE delete-previous-word
|
||||||
alt pressed DELETE delete-next-word
|
alt pressed DELETE delete-next-word
|
||||||
|
|||||||
Reference in New Issue
Block a user