views:

435

answers:

1

Have a class that extends JDialog. It's initialized entirely on EDT (just in case). Now,

public PropsDialog (JFrame parentFrame) {
    super(parentFrame);
    // boring
    pack();
    setLocationRelativeTo(getParent());
    setVisible(true);

results in dialog appearing in the leftmost corner and then jumping to it's intended position. Am I doing smth wrong?

+1  A: 

Could you provide a working example and more information? For example, on what operating system are you testing on? Swing has some differences between some, e.g. JDialogs without a parent getting an entry in the gnome panel but not in the windows taskbar and things like that.

Secondly, I would guess, that your JDialog is visible before you call setLocationRelativeTo, maybe through somewhat within the part you commented out as "boring". I would suggest, you punch a quick

System.out.println(isVisible());

into your code, just before setLocationRelativeTo, just in case...

Tim Büthe
You were close :).Refactoring the dialog to extend JDialog, i missed out the show() call on it. This method previously fired a call to JOptionPane that in turn displayed a JDialog and been removed during refactoring. But as class extends JDialog now, the show() call actually sets it visible.
alex