diff --git a/CHANGELOG.md b/CHANGELOG.md index e7f3c04e..96fc8126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ FlatLaf Change Log current theme (look and feel). - Made disabled text color slightly lighter in dark themes for better readability. (issue #174) +- PasswordField: Support disabling Caps Lock warning icon. (issue #172) #### Fixed bugs diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java index 0ca2abda..d4e615c3 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java @@ -60,6 +60,7 @@ import com.formdev.flatlaf.util.HiDPIUtils; * @uiDefault Component.minimumWidth int * @uiDefault Component.isIntelliJTheme boolean * @uiDefault PasswordField.placeholderForeground Color + * @uiDefault PasswordField.showCapsLock boolean * @uiDefault PasswordField.capsLockIcon Icon * @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always * @@ -71,6 +72,7 @@ public class FlatPasswordFieldUI protected int minimumWidth; protected boolean isIntelliJTheme; protected Color placeholderForeground; + protected boolean showCapsLock; protected Icon capsLockIcon; private FocusListener focusListener; @@ -88,6 +90,7 @@ public class FlatPasswordFieldUI minimumWidth = UIManager.getInt( "Component.minimumWidth" ); isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" ); placeholderForeground = UIManager.getColor( prefix + ".placeholderForeground" ); + showCapsLock = UIManager.getBoolean( "PasswordField.showCapsLock" ); capsLockIcon = UIManager.getIcon( "PasswordField.capsLockIcon" ); LookAndFeel.installProperty( getComponent(), "opaque", false ); @@ -160,6 +163,9 @@ public class FlatPasswordFieldUI } protected void paintCapsLock( Graphics g ) { + if( !showCapsLock ) + return; + JTextComponent c = getComponent(); if( !FlatUIUtils.isPermanentFocusOwner( c ) || !Toolkit.getDefaultToolkit().getLockingKeyState( KeyEvent.VK_CAPS_LOCK ) ) diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index ead914d8..cf608e79 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -393,6 +393,7 @@ PasswordField.margin=@textComponentMargin PasswordField.background=@textComponentBackground PasswordField.placeholderForeground=@disabledText PasswordField.echoChar=\u2022 +PasswordField.showCapsLock=true PasswordField.capsLockIcon=com.formdev.flatlaf.icons.FlatCapsLockIcon diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202.txt b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202.txt index 2f9e976f..c734a7a1 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202.txt +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202.txt @@ -652,6 +652,7 @@ PasswordField.margin 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI] PasswordField.placeholderForeground #888888 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionBackground #4b6eaf javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionForeground #bbbbbb javax.swing.plaf.ColorUIResource [UI] +PasswordField.showCapsLock true PasswordFieldUI com.formdev.flatlaf.ui.FlatPasswordFieldUI diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202.txt b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202.txt index c7dade83..98953b70 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202.txt +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202.txt @@ -657,6 +657,7 @@ PasswordField.margin 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI] PasswordField.placeholderForeground #8c8c8c javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionBackground #2675bf javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionForeground #ffffff javax.swing.plaf.ColorUIResource [UI] +PasswordField.showCapsLock true PasswordFieldUI com.formdev.flatlaf.ui.FlatPasswordFieldUI diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatTestLaf_1.8.0_202.txt b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatTestLaf_1.8.0_202.txt index bda10372..990177b5 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatTestLaf_1.8.0_202.txt +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatTestLaf_1.8.0_202.txt @@ -649,6 +649,7 @@ PasswordField.margin 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI] PasswordField.placeholderForeground #000088 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionBackground #00aa00 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionForeground #ffff00 javax.swing.plaf.ColorUIResource [UI] +PasswordField.showCapsLock true PasswordFieldUI com.formdev.flatlaf.ui.FlatPasswordFieldUI diff --git a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt index dcf47d78..26f37430 100644 --- a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt +++ b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt @@ -452,6 +452,7 @@ PasswordField.margin PasswordField.placeholderForeground PasswordField.selectionBackground PasswordField.selectionForeground +PasswordField.showCapsLock PasswordFieldUI Popup.dropShadowColor Popup.dropShadowInsets