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

Calling Component.setEnabled during IME usage causes deadlock

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 1.3.1_03
    • 1.3.0
    • client-libs
    • 03
    • x86
    • windows_2000

    Backports

      Description



        Name: yyT116575 Date: 03/05/2001


        java version "1.3.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
        Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

        This small program puts up a window with a textfield and a button, with the
        button tied to the field such that it is disabled if the textfield is empty.

        import javax.swing.*;
        import javax.swing.text.*;
        import javax.swing.event.*;

        public class Main{
          public static void main(String args[]){
            JFrame frame = new JFrame();
            JPanel panel = new JPanel(new java.awt.GridLayout(2,1));
            
            final JTextField textField = new JTextField(15);
            panel.add(textField);
            
            final JButton button = new JButton("Button");
            button.setEnabled(false);
            panel.add(button);
            
            textField.getDocument().addDocumentListener(new DocumentListener(){
                public void insertUpdate(DocumentEvent e) {
                    button.setEnabled(e.getDocument().getLength() != 0);
                }
          
                public void removeUpdate(DocumentEvent e) {
                    button.setEnabled(e.getDocument().getLength() != 0);
                }
          
                public void changedUpdate(DocumentEvent e) {
                    button.setEnabled(e.getDocument().getLength() != 0);
                }
            });
            
            frame.getContentPane().add(panel);
            frame.pack();
            frame.setVisible(true);
          }
        }

        On a Japanese Windows machine, set the IME to Hiragana and enter some text that
        will be converted, e.g. "hyou". When the IME translates the text it removes the
        old characters and adds the new, causing DocumentEvents to be generated, and
        button.setEnabled to be called. About one time in five, setEnabled will not
        return, locking up the program. The stack trace looks like this:

        "AWT-EventQueue-0" prio=7 tid=0x823a30 nid=0x708 runnable [0x8e6f000..0x8e6fdc4]
                at sun.awt.windows.WGlobalCursorManager.setCursor(Native Method)
                at sun.awt.GlobalCursorManager._updateCursor(Unknown Source)
                at sun.awt.GlobalCursorManager.updateCursorImmediately(Unknown Source)
                at java.awt.Component.disable(Unknown Source)
                at javax.swing.JComponent.disable(Unknown Source)
                at java.awt.Component.enable(Unknown Source)
                at java.awt.Component.setEnabled(Unknown Source)
                at javax.swing.JComponent.setEnabled(Unknown Source)
                at javax.swing.AbstractButton.setEnabled(Unknown Source)
                at Main$1.removeUpdate(Main.java:23)
                at javax.swing.text.AbstractDocument.fireRemoveUpdate(Unknown Source)
                ...
        (Review ID: 118031)
        ======================================================================

        Attachments

          Issue Links

            Activity

              People

                naoto Naoto Sato
                yyoungsunw Yung-ching Young (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: