Linux下PasswordField暂时无法输入

2014-11-24 09:26:56 · 作者: · 浏览: 0

今天做练习时遇到的问题:


Linux下PasswordField无法输入,只有把光标从密码框移开,让密码框重新获得焦点,可以输入了。一开始以为是java的bug。后来知道是因为PasswordField组件默认不获取系统输入法支持,需要自己设置。


加入 userPasswordInput.enableInputMethods(true); 运行程序ok,可以输入了。


详见文档说明:


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).