-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
03
-
x86
-
windows_2000
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2041200 | 1.4.0 | Naoto Sato | P3 | Resolved | Fixed | beta2 |
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)
======================================================================
- backported by
-
JDK-2041200 Calling Component.setEnabled during IME usage causes deadlock
- Resolved