diff --git a/src/macosx/classes/com/apple/laf/AquaKeyBindings.java b/src/macosx/classes/com/apple/laf/AquaKeyBindings.java index bbb804ae3f10429d36641c5f926b1a64bb803688..88db59f0b9fb51e22e0699d89ebb940a0106e1bb 100644 --- a/src/macosx/classes/com/apple/laf/AquaKeyBindings.java +++ b/src/macosx/classes/com/apple/laf/AquaKeyBindings.java @@ -142,6 +142,21 @@ public class AquaKeyBindings { })); } + LateBoundInputMap getPasswordFieldInputMap() { + return new LateBoundInputMap(new SimpleBinding(getTextFieldInputMap().getBindings()), + // nullify all the bindings that may discover space characters in the text + new SimpleBinding(new String[] { + "alt LEFT", null, + "alt KP_LEFT", null, + "alt RIGHT", null, + "alt KP_RIGHT", null, + "shift alt LEFT", null, + "shift alt KP_LEFT", null, + "shift alt RIGHT", null, + "shift alt KP_RIGHT", null, + })); + } + LateBoundInputMap getMultiLineTextInputMap() { return new LateBoundInputMap(new SimpleBinding(commonTextEditorBindings), new SimpleBinding(new String[] { "ENTER", DefaultEditorKit.insertBreakAction, diff --git a/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java b/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java index 4f108da2df053aa5d2cce99dd39ef48dba16c2e0..457b82d36a31ef25f43cc38e4946ccc6989487d6 100644 --- a/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java +++ b/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java @@ -697,7 +697,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel { "Panel.foreground", black, "Panel.opaque", useOpaqueComponents, - "PasswordField.focusInputMap", aquaKeyBindings.getTextFieldInputMap(), + "PasswordField.focusInputMap", aquaKeyBindings.getPasswordFieldInputMap(), "PasswordField.font", controlFont, "PasswordField.background", textBackground, "PasswordField.foreground", textForeground, diff --git a/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java b/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java index 7532f6201495a3d72cf5e5cc16dab83c85a724fc..ef2b4d087e2728325d527dd16a9fac4e6796eef7 100644 --- a/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java +++ b/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java @@ -34,7 +34,7 @@ import java.awt.event.ActionListener; import java.awt.event.FocusEvent; import java.awt.peer.TextFieldPeer; -import javax.swing.JPasswordField; +import javax.swing.*; import javax.swing.text.JTextComponent; final class LWTextFieldPeer @@ -48,7 +48,7 @@ final class LWTextFieldPeer @Override protected JPasswordField createDelegate() { - return new JTextAreaDelegate(); + return new JPasswordFieldDelegate(); } @Override @@ -69,9 +69,18 @@ final class LWTextFieldPeer public void setEchoChar(final char echoChar) { synchronized (getDelegateLock()) { getDelegate().setEchoChar(echoChar); - getDelegate().putClientProperty("JPasswordField.cutCopyAllowed", - getDelegate().echoCharIsSet() - ? Boolean.FALSE : Boolean.TRUE); + final boolean cutCopyAllowed; + final String focusInputMapKey; + if (echoChar != 0) { + cutCopyAllowed = false; + focusInputMapKey = "PasswordField.focusInputMap"; + } else { + cutCopyAllowed = true; + focusInputMapKey = "TextField.focusInputMap"; + } + getDelegate().putClientProperty("JPasswordField.cutCopyAllowed", cutCopyAllowed); + InputMap inputMap = (InputMap) UIManager.get(focusInputMapKey); + SwingUtilities.replaceUIInputMap(getDelegate(), JComponent.WHEN_FOCUSED, inputMap); } } @@ -106,11 +115,11 @@ final class LWTextFieldPeer super.handleJavaFocusEvent(e); } - private final class JTextAreaDelegate extends JPasswordField { + private final class JPasswordFieldDelegate extends JPasswordField { // Empty non private constructor was added because access to this // class shouldn't be emulated by a synthetic accessor method. - JTextAreaDelegate() { + JPasswordFieldDelegate() { super(); }