<Swing Dev> TextArea's/TextField's enableInputMethods is not working on linux

Charles Lee littlee at linux.vnet.ibm.com
Tue Dec 6 07:02:05 UTC 2011


On 05/27/2011 03:18 AM, Naoto Sato wrote:
> It simply sounds like a bug to me. The behavior should not be different.
>
> Naoto
>
> (5/26/11 12:25 AM), Sean Chou wrote:
>> Hi all,
>>
>>     I found TextArea's/TextField's enableInputMethods is not working on
>> linux,
>> even enableInputMethods(false) is invocated, the input method can 
>> still be
>> enabled.  The testcase is as follows:
>>
>> /*
>>   * ImfAWTTest.java
>>   */
>> import java.awt.Component;
>> import java.awt.Dimension;
>> import java.awt.FlowLayout;
>> import java.awt.Frame;
>> import java.awt.TextArea;
>> import java.awt.TextField;
>> import java.awt.event.WindowAdapter;
>> import java.awt.event.WindowEvent;
>>
>> import javax.swing.JTextArea;
>> import javax.swing.JTextField;
>>
>>
>> public class ImfAWTTest extends Frame {
>> Component c;
>> public ImfAWTTest() {
>> super("Single Frame --- AWT Frame");
>> // set layout here.
>> setLayout(new FlowLayout());
>> // add components here.
>> c = new TextArea("TextArea component(No IM)");
>> c.enableInputMethods(false);
>> c.setPreferredSize(new Dimension(400, 100));
>> add(c);
>>
>> c = new JTextArea("JTextArea component");
>> c.enableInputMethods(true);
>> c.setPreferredSize(new Dimension(400, 100));
>> add(c);
>>
>> c = new TextField("TextField component(No IM)",52);
>> c.enableInputMethods(false);
>> add(c);
>>
>> c = new JTextField("JTextField component(No IM)");
>> c.enableInputMethods(false);
>> c.setPreferredSize(new Dimension(400, 20));
>> add(c);
>> addWindowListener(new WindowAdapter() {
>> public void windowClosing(WindowEvent event) {
>> System.exit(0);
>> }
>> });
>> setSize(850, 360);
>> setVisible(true);
>> }
>> public static void main(String[] args) {
>> new ImfAWTTest();
>> }
>> }
>>
>>
>> Reproduce steps are:
>> 1. On linux system, run the testcase with b143.
>> 2.  Click 'TextArea component(No IM)'.
>> 3. Switch Ime window, and type some characters into it
>>
>> Expectation:
>>    IME cannot be enabled.
>> Result:
>>    IME can be used to input.
>>
>>
>> Investigation:
>>     This behavior was developed when Java was using Motif library,
>> however Java7's
>> TextArea/TexField does not use Motif any more, so enableInputMethods 
>> doesn't
>> work.
>>
>>
>>     I suppose we need to update the specification about the behavior.
>> Any comments?
>>
>>
>> -- 
>> Best Regards,
>> Sean Chou
>>
>
Hi all,

Here is a little progress on this issue.

The reason that enableInputMethod(false) does not take any effect is 
that in XTextFieldPeer/XTextAreaPeer init, they will do 
target.enbleInputMethods(true), which is re-enable the input methods again.
Once I was thinking the fixes should be easy. Just do not set the 
enbleInputMethods(true) should do the trick. But I was found that 
X****Peer was also required to set the inputMethods. Unfortunately, we 
can not get any info about input methods from the target. (Is there 
any?) The "areInputMethodsEnabled" method is package private ....

Any expertise can help on this issue? Thanks in advance.

-- 
Yours Charles




More information about the core-libs-dev mailing list