Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6306625

Uncomitted characters are lost when the focus is moved to another textfield by mouse click

XMLWordPrintable

    • b01
    • x86
    • windows_xp

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

              yyamasaksunw Yuriko Yamasaki (Inactive)
              mmma Marvin Ma (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: