setLocation on a JDialog is ignored
Hello-
I'm trying to set the location of a JDialog.
For some reason my setLocation() call seems to be ignored, and the JDialog just remains at 0,0 all the time.
Does anyone know what I'm doing wrong?
I've created a simple class below which illustrates the issue:
import javax.swing.*;
import java.awt.event.*;
public class JDialogTest {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setVisible(true);
frame.setLocation(300,300);
frame.setSize(300,300);
JDialog dialog = new JDialog(frame, true /*modal*/);
dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
dialog.add(new JLabel("Test"));
dialog.pack();
dialog.setVisible(true);
dialog.setLocation(200,200);
}
}
My setLocation(200,200) call is ignored, and the dialog remains at 0,0 (upper left corner of the screen).
Interestingly, the frame.setLocation(300,300) is accepted, and you can see the frame is at 300,300.
What do you think?
-scott