dialog problem

C

cmk128

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])
 
K

Knute Johnson

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);
}
}
 
C

cmk128

Hi Johnson
I fixed the problem, because i was calling the method like this:
new JDialog().setVisible(true);

If i change to this
new JDialog(this).setVisible(true);

It will be fixed.
thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,133
Latest member
MDACVReview
Top