Try this :
import java.awt.Window;
import javax.swing.JDialog;
public class Test {
public static void main(String[] args) {
JDialog d = new JDialog((Window)null,"Demo Dialog");
for (Window w : JDialog.getWindows()) {
if ( w instanceof JDialog) {
System.out.println(((JDialog)w).getTitle());
}
}
}
}
And if you are puzzled by the :
(Window)null
cast, simply try to compile without it :)
(BTW passing a null window to the constructor creates an unowned dialog)
EDIT: Please note that this will give you references to ALL dialogs regardless of whether they are visible as the code demonstrates. To fix it simply query the dialog on whether it is visible by using isVisible()