JOptionPane.getWindowForComponent(parent)

Window is a superclass of Frame and Dialog. And in 1.6 there is

a constructor of JDialog that accept Window as owner,

but I can't use it!

JOptionPane.getWindowForComponent()

is a static method that is not public, and I don't understand the reason!

Because when I create a JDialog over a frame or over another dialog, I must use

a method like this:

public void openDialog(Component parent) {

if (parent instanceof JDialog)

jDialog = new JDialog((JDialog)parent);

else {

Frame frame = JOptionPane.getFrameForComponent(parent);

jDialog = new JDialog(frame);

}

....

but using that method could be simple and better:

public void openDialog(Component parent) {

jDialog = new JDialog(JOptionPane.getWindowForComponent(parent));

.....

What is your opinion?

Should this method made public?

[911 byte] By [nttmana] at [2007-11-26 16:57:07]
# 1
Use SwingUtilities instead:SwingUtilities.getWindowAncestor(parent)
Rodney_McKaya at 2007-7-8 23:24:50 > top of Java-index,Desktop,Core GUI APIs...