Reputation: 1618
I have a problem with inconsistence behavior of JPasswordField component trying to use Asian composite characters.
My code is:
final JCheckBox visiblePassword = new JCheckBox(); // show/hide password checkbox
JPasswordField passwordField = new JPasswordField();
passwordField.setPreferredSize(new Dimension(200, 25));
final char echoChar = passwordField.getEchoChar();
visiblePassword.addActionListener(new ActionListener() // show/hide password
{
public void actionPerformed(ActionEvent evt)
{
if(visiblePassword.isSelected()) passwordField.setEchoChar((char)0);
else passwordField.setEchoChar(echoChar);
}
});
My goal is to allow all characters in entered password.
However:
Windows 8 - It does not work at all (only Latin characters are allowed - IME does not work).
Mac OS X - Korean characters are allowed (but it doesn't join them to one character), Japanese and Chinese doesn't work at all.
I'm able to find discussions and solutions of this issue for other platform like for iOS here:
Selecting language of the keyboard for UITextField with secureTextEntry
however nothing for Java swing.
So before I start an implementation of a custom version of "JPasswordField" I would like to ask:
Does anyone solve this problem or do you know about some other component like JPasswordField, but suitable for my needs?
Upvotes: 2
Views: 377
Reputation: 9818
Did you know this link? JPasswordField (Java Platform SE 8 )
NOTE: By default, JPasswordField disables input methods; otherwise, input characters could be visible while they were composed using input methods. If an application needs the input methods support, please use the inherited method, enableInputMethods(true).
Upvotes: 2