JDK-4730228 : Can't activate IME Japanese input mode in Applet running on Java plug-in
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-08-12
  • Updated: 2003-02-25
  • Resolved: 2002-11-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other Other Other
1.3.1_07 07Fixed 1.4.0_04Fixed 1.4.1_03Fixed 1.4.2Fixed
Description

Name: pa48320			Date: 08/12/2002


[Problem]
I can't activate Japanese input mode in the LWTextField that is initially
focused on the Applet. LWTextField is a component of our AWT-based UI framework
called EWT, it looks like a java.awt.TextField,
and it is implemented on java.awt.Component.

When I run an Applet with the LWTextField and set the initial
focus to it by calling requestFocus() method,
the cursor is set to it and I can input English letters.
But if I try to toggle the Japanese input mode by typing (ALT)+(`) key,
that is the typical way to toggle the Japanese IME in Windows system,
nothing happens and the input mode is still in English mode.

If I move a focus to another component by hitting tab key then get back
to it, or click the LWTextField, it turns to be IME enabled.

This problem doesn't occur when I use the appletviewer instead of
Java plug-in.

This problem doesn't happen when I use java.awt.TextField instead of
LWTextField.

Why we decided to file a bug to ask your help is because
EWT doesn't have any code that deals with IMEs.
EWT just relies on what Sun provides.

We continue to work on this problem and we will
let you know when we find anything new as soon as possible.


[Environments on which the bug occurs]
java version "1.3.1_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_04-b02)
Java HotSpot(TM) Client VM (build 1.3.1_04-b02, mixed mode)

Windows 2000 Japanese version
Microsoft Windows 2000 [Version 5.00.2195]
Build 2195: Service Pack 2

Netscape 6.2.3 (Japanese version)
Mozilla/5.0 (Windows; U; Windows NT 5.0; ja-JP; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3

IE 5.5 (Japanese version)
version 5.50.4807.2300
Update versions: SP2; Q321232;



[Reproduce Procedure]
1. Compile the testcase java source with EWT library
2. Setup Java plug-in
3. Access the testcase html file from browser
4. Type (ALT) + (`) to toggle Japanese input mode

  To compile and run the testcase, you need EWT library.
Would you please contact me? then I can send it to you.


[Expected and Actual Results]
If you access the html file from your browser,
you will see the 2 text field on the browser, and
the focus is on the left text field.
The expected result is that you can toggle the Japanese input mode.
But the actual result is that you can't toggle
the Japanese input mode even if you type (ALT) + (`) key.




[Source Code : FocusApp2.java]
import oracle.ewt.lwAWT.lwText.LWTextField;
import java.applet.Applet;

public class      FocusApp2
       extends    Applet
{
  LWTextField mText1;
  LWTextField mText2;

  public void start()
  {
    mText1 = new LWTextField("LWTextField1");
    mText2 = new LWTextField("LWTextField2");

    this.add(mText1);
    this.add(mText2);

    mText1.requestFocus();
  }
}

[Source Code : test.html]
<HTML>
<HEAD><TITLE>Java Plug-in</TITLE></HEAD>

<BODY>
<P>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    width="1024" height="768" align="baseline"
    codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
<PARAM NAME="code" VALUE="FocusApp2">
<PARAM NAME="archive" VALUE="share-dbg.jar,ewt3-dbg.jar">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<COMMENT>
    <EMBED type="application/x-java-applet;version=1.3" width="1024"
       height="768" align="baseline" code="FocusApp2" archive="share-dbg.jar,ewt3-dbg.jar"
       pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html">
    <NOEMBED>
    </COMMENT>
           No Java 2 SDK, Standard Edition v 1.3 support for APPLET!!
    </NOEMBED></EMBED>
</OBJECT>
</BODY>
</HTML>
(Review ID: 160161) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.1_07 1.4.0_04 1.4.1_03 mantis FIXED IN: 1.3.1_07 1.4.0_04 1.4.1_03 mantis INTEGRATED IN: 1.3.1_07 1.4.0_04 1.4.1_03 mantis mantis-b08
24-08-2004

EVALUATION The test case consists of an applet that includes two Oracle's lightweight text fields. The problem happens intermittently, and in case of the problem, a focus gained event is dispatched while the applet is hidden. The input method framework tries to attach an input context to the native window which is associated to the peer for the applet. Since the native window is hidden, attaching the input context fails. ###@###.### 2002-08-23 According to ###@###.###, this happens in 1.4.1 RC as well. ###@###.### 2002-08-26 We should try to investigate this for Mantis or Tiger. ###@###.### 2002-09-04 Name: dmR10075 Date: 09/13/2002 What I see in 1.3.1 is that focus events(FOCUS_GAINED) arrive to hidden invalid component. It happens because requestFocus doesn't verify that requested component is heirarchyly visible and at the time when applet's start is called applet is not yet visible. It becomes visible only _after_ start. As Naoto pointed, FOCUS_GAINED to invisible component might cause problems to IMF. Unfortunately, in this case we can't just block FOCUS_GAINED - or applet will be unable to make some components focus owners on start. I think better idea is to either make IMF more durable to focus events or make applet visible in start() method. The latter I hope is the acceptable workaround for customer. It might also be helpfull to add validate() call as well. ###@###.### 2002-09-13 ====================================================================== Name: dmR10075 Date: 09/13/2002 sun/applet/AppletPanel.java makes applet visible and valid after start. As the way of fixing the problem we can move the call setVisible(true) before call to start. Also, it seems a lot of users request focus in start() method so it might be even more reasonable. Though I find it dangerous change becuase I don't understand why it wasn't made so before - may be there were some problems related to this? Note that this code havn't changed in 1.4.x, it might be reasonable to update all releases. ###@###.### 2002-09-13 ====================================================================== Name: dmR10075 Date: 10/23/2002 After investigation with Arun we found that there is some native code which actually cleans IME context associated with window when window is being shown. That's why when FOCUS_GAINED arrives to invisible component and IME associates context with it it still doesn't have context associated when it is accessed by first time. Here is this code(awt_Component.cpp - WmShowWindow): // NULL-InputContext is associated to all window just after they created. // ( see CreateHWnd() ) // But to TextField and TextArea on Win95, valid InputContext is associated // by system after that. This is not happen on NT4.0 // For workaround, force context to NULL here. if (ImmGetContext(m_hwnd)) ImmAssociateContext(m_hwnd, NULL); return mrDoDefault; Note that this code is reasonable until we notice that ImmGetContext might return not the default Windows context(as on Windows 95) but our own installed context. So, to fix thix we should make sure we don't clear our own context. ###@###.### 2002-10-22 ======================================================================
22-10-2002

SUGGESTED FIX Name: dmR10075 Date: 10/23/2002 ------- awt_Component.cpp ------- *** /tmp/sccs.zUaySl Tue Oct 22 18:21:20 2002 --- awt_Component.cpp Tue Oct 22 18:16:57 2002 *************** *** 1872,1879 **** // But to TextField and TextArea on Win95, valid InputContext is associated // by system after that. This is not happen on NT4.0 // For workaround, force context to NULL here. ! if (ImmGetContext(m_hwnd)) ! ImmAssociateContext(m_hwnd, NULL); return mrDoDefault; } --- 1872,1890 ---- // But to TextField and TextArea on Win95, valid InputContext is associated // by system after that. This is not happen on NT4.0 // For workaround, force context to NULL here. ! ! // Fix for 4730228 ! // Check if we already have Java-associated input method ! jint context = 0; ! if (m_InputMethod != NULL) { ! // If so get the appropriate context from it and use it instead of empty context ! JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); ! context = JNU_GetFieldByName(env, NULL, m_InputMethod, "context", "I").i; ! } ! ! if (ImmGetContext(m_hwnd)) { ! ImmAssociateContext(m_hwnd, (HIMC)context); ! } return mrDoDefault; } ###@###.### 2002-10-22 ======================================================================
22-10-2002

WORK AROUND Name: pa48320 Date: 08/12/2002 If I use JDK1.4/Java plug-in 1.4 and use java.awt.Component.requestFocusInWindow() method to focus the text field, I can activate the Japanese input mode at the initial focused field. But we need to support this functionality in plug-in 1.3 because some part of our technologies still depends on 1.3. ====================================================================== Name: dmR10075 Date: 09/13/2002 Add show() and validate() as the first statements in the applet's start method. ###@###.### 2002-09-13 ======================================================================
13-09-2002