-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.5
-
x86
-
windows_nt
Name: rk38400 Date: 04/11/98
Creation of a modal dialog box will hang up
if the call is within a synchronized block. The
dialog box may or not get painted, but the whole
system will quickly become unresponsive, and no
further window repainting will be done.
I will attach source below which demonstrates the
problem.
This bug is probably related to #4034834, which
was posted over a year ago.
This badly needs to be fixed, or at least properly
documented.
Thanks,
--Mike
import com.sun.java.swing.*;
import java.awt.event.*;
import java.io.*;
public class DialogBug extends JFrame {
public DialogBug() {
JButton goodButton = new JButton("This works");
goodButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { good(); }
});
JButton badButton = new JButton("But this hangs");
badButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { bad(); }
});
getContentPane().add(goodButton, "West");
getContentPane().add(badButton, "East");
pack();
}
public void good() {
JOptionPane.showMessageDialog(null, "We're cool!", "Modal Dialog",
JOptionPane.INFORMATION_MESSAGE);
synchronized (this) {
notify();
}
}
public synchronized void bad() {
JOptionPane.showMessageDialog(null, "We're hosed!", "Modal Dialog",
JOptionPane.ERROR_MESSAGE);
notify();
}
public synchronized void showAndWait() throws InterruptedException {
show();
wait();
}
public static void main(String[] args) {
DialogBug db = new DialogBug();
try {
db.showAndWait();
} catch (InterruptedException e) {
}
}
}
(Review ID: 26253)
======================================================================
- duplicates
-
JDK-4034834 Unable to use modal dialogs when something locks Component.LOCK
-
- Closed
-