<AWT Dev> [8] Review request for 6789984: JPasswordField can not receive keyboard input

Anton Litvinov anton.litvinov at oracle.com
Mon Nov 5 02:42:50 PST 2012


Hello Sergey,

Thank you for the review. In the beginning I also wanted to omit this 
code duplication and to substitute these two lines of code for
     ((InputMethodAdapter)inputMethod).stopListening();
But then I decided not to do this, because "sun.awt.im.InputContext" is 
shared between code oriented to different platforms, where 
implementations of "stopListening()" and "disableInputMethod()" can be 
different from those which are in "sun.awt.X11InputMethod", and 
substitution of "disableInputMethod()" for "stopListening()" could break 
existing functionality of method
     public void disableNativeIM()
of "sun.awt.im.InputContext" on platforms other then Linux and Solaris.

A key moment of the proposed fix is an obligatory call to "resetXIC()" 
method of "sun.awt.X11InputMethod" after disabling of the input method. 
A cause of the bug and an explanation of the proposed solution are 
provided in my last comment on the page of this bug.

A call to "endComposition()" method inside "disableNativeIM()" of 
"sun.awt.im.InputContext" was added for resolution of another problem 
which was additionally observed. The problem consists in the fact that 
some not completely composed text inside JTextField can stay in not 
completed state after the focus is moved from JTextField to 
JPasswordField. This not completed text marked with underscore 
disappears from JTextField at the moment when JTextField receives focus 
again. So I decided to make such a text disappear at a moment when a 
component with disabled input methods, in current case JPasswordField, 
receives focus by a call to "endComposition()" method. Perhaps, this 
call could be removed from the fix, because absence of end of text 
composition during switch of focus between component with enabled and 
disabled input methods can be another separate issue.

Thank you,
Anton

On 11/2/2012 5:03 PM, Sergey Bylokhov wrote:
> Hi Anton,
> I am not an expert in this area, but probably
>
>  789             inputMethod.endComposition();
>  790             ((InputMethodAdapter)inputMethod).disableInputMethod();
>
> can be changed to stopListening()?
>
> Since some code duplication was added in the 
> fix(stopListening/disableNativeIM/disableInputMethod)
>
> 01.11.2012 20:40, Anton Litvinov wrote:
>> Hello,
>>
>> Please review the following fix for a bug.
>>
>> Bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6789984
>> Webrev: http://cr.openjdk.java.net/~alitvinov/6789984/webrev.00
>>
>> This bug consists in inability of JPasswordField to react on any 
>> keyboard events under certain conditions on Linux OS. The webrev does 
>> not contain any new "jtreg" test, because a particular Linux OS 
>> distribution with additionally installed packages are required for 
>> reproduction of the bug.
>>
>> Requirements to the environment:
>> 1. Oracle Enterprise Linux (OEL) 5.6 x86 64/Oracle Enterprise Linux 
>> (OEL) 5.5 x86 64
>> 2. Package "scim-anthy-1.2.0-6.el5.x86_64" and its all dependent 
>> packages installed on the OS.
>> 3. JDK 8.
>> 4. A simple Java Swing application, where a dialog with both 
>> JTextField and JPasswordField is displayed.
>>
>> Thank you,
>> Anton
>
>



More information about the awt-dev mailing list