United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6306625 : Uncomitted characters are lost when the focus is moved to another textfield by mouse click

Details
Type:
Bug
Submit Date:
2005-08-04
Status:
Resolved
Updated Date:
2014-02-27
Project Name:
JDK
Resolved Date:
2006-08-08
Component:
client-libs
OS:
windows_xp
Sub-Component:
java.awt:i18n
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:
5.0u10 (b01)

Related Reports
Backport:
Relates:
Relates:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java 1.4.2

ADDITIONAL OS VERSION INFORMATION :

Microsoft Windows XP Version 2002 Service Pack 1.


EXTRA RELEVANT SYSTEM CONFIGURATION :
IME configuration:
KeyBoard: Microsoft IME standard 2002 ver 8.1
InputStyle: IME standard
InputMode: Hiragana
Conversion Mode: General
on Microsoft Windows XP Version 2002 Service Pack 1.


A DESCRIPTION OF THE PROBLEM :
The reason for the above issue is that java.awt.event.InputMethodEvent is not generated when we try to shift the focus by clicking on other component, and thus our IME event listener implementation.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
There are two text fields JTextField, when u click the other text field the focus change but IME event is not fired if it is not fired then we cannot listen to the callback method and thus we will be not able to update the committed text.

When we set the IME configuration as described above then we get the IME event generated for each typing but when we change the focus via mouse (if we change the focus via tab the evnet is fired) the IME event is not generated.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"IME EVent" is printed on the console  when the IME event is fired, this will not be printed when we change the focus via mouse click while if  we type in something in the left hand side text field we get the print outs and also if we tab and shift focus we again get the print outs.

Please note the listener is attached to the left TextField.


ACTUAL -
I should be able to listen to this listener even when I change the focus via Mouse click.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.FlowLayout;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
import javax.swing.JApplet;
import javax.swing.JTextField;

public class TrialTextField extends JApplet
{
  public TrialTextField()
  {
  }
  
  public void init()
  {
    TrialTextField trialTextField = new TrialTextField();
    JTextField textfield = new JTextField("Testing IME ");
    
    JTextField text1 = new JTextField("Testing The IME");
    textfield.addInputMethodListener(
    new InputMethodListener()
    {
      public void inputMethodTextChanged(InputMethodEvent event)
      {
        System.out.println("IME EVent");
      }
      
       public void caretPositionChanged(InputMethodEvent event)
       {
         System.out.println("IME EVent in Caret CHange");
       }
    });
    this.getContentPane().setLayout(new FlowLayout());
    this.getContentPane().add(textfield);
    textfield.addInputMethodListener(
    new InputMethodListener()
    {
      public void inputMethodTextChanged(InputMethodEvent event)
      {
        System.out.println("IME EVent");
      }
      
       public void caretPositionChanged(InputMethodEvent event)
       {
         System.out.println("IME EVent in Caret CHange");
       }
    });
    this.getContentPane().add(text1);
  }
  
  public void start()
  {
    
  }
  
 
}


Html file:
<!-- $Name:  $ ($Revision: 1.5 $) $Date: 1997/09/10 00:41:34 $ -->
<title>Lightweight Text Field Demo</title>
<hr>
<applet code="TrialTextField.class" width=620 height=400>
</applet>
<hr>
<a href="LWTextDemo.java">The source.</a>

---------- END SOURCE ----------

                                    

Comments
EVALUATION

Hi.
Thank you for the additional comments. 

This problem is seen only prior to Mustang (Java 6). 
With Mustang, it behaves correctly. 

The issues that I observed:
1. uncomitted characters are lost when the focus is moved to another textfield by mouse click; however the same uncomitted characters get comitted when the focus is moved by pressing TAB key.
2. Uncomitted characters in JApplet and in JFrame get lost in different timing when the focus is moved by mouse click:
   a.) JApplet: uncomitted characters remain as is (underlined) till the focus is back and a new uncomitted character is typed
   b.) JFrame: uncomitted characters disappear as soon as the focus is moved to another textfield.

I'm attaching the the test program with minor correction (eg. one listener per textfield etc. )
                                     
2006-04-20
EVALUATION

Hi.

My above evaluation may not follow what this CR is describing. 
I'd like to get more specific step-by-step information of how to reproduce this bug from the submitter.

Here is what we tried:
1. Run the test case.
2. Change the IME to HIRAGANA mode (Click on the "Input Mode" button in the language bar, then select "Hiragana")
3. Type "a" key, which shows up in the text field as a Hiragana composed text.
4. Either pressing TAB, or click the right text field by mouse, which commits the composed text and moves the input focus. 

Using above steps, we'll see the expected behavior. 
Changing the status of this CR as "Incomplete - Need more info" till we get the step-by-step reproducible steps.
Thanks.
                                     
2006-04-11
EVALUATION

When the caret position is moved by arrow key, INPUT_METHOD_TEXT_CHANGED event is generated, and the input can be inserted in the position; however, when the caret is moved by a mouse, no InputMethod Event is generated, and the following letter typed will be appended at the end of the composed text.  The behavior is consistent both Solaris 10 and Windows XP using Mustang.
                                     
2006-03-16



Hardware and Software, Engineered to Work Together