Hi
when a jframe show a modal jdialog and that jdialog show another
modalness jdialog. The modalness dialog is un-close-able, how to avoid
it?
thanks
from Peter (
[email protected])
Peter:
I don't see your problem with my test code. Please post a compilable
example that demonstrates your problem.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test7 {
public static void main(String[] args) {
Runnable r = new Runnable() {
public void run() {
final JFrame f = new JFrame("test7");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton b = new JButton("Open Modal Dialog");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
final JDialog modalDialog = new
JDialog(f,"Modal",true);
JButton b = new JButton("Open Non-Modal Dialog");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JDialog nonModalDialog =
new
JDialog(modalDialog,"Non-Modal",false);
JLabel l = new JLabel("Non-Modal Dialog");
nonModalDialog.add(l);
nonModalDialog.pack();
nonModalDialog.setVisible(true);
}
});
modalDialog.add(b);
modalDialog.pack();
modalDialog.setVisible(true);
}
});
f.add(b);
f.pack();
f.setVisible(true);
}
};
EventQueue.invokeLater(r);
}
}