java - How to check if JDialog's has no parent? -
jdialog
created parent set null
. so:
final jpanel dialogpanel = new jpanel(); joptionpane optionpane = new joptionpane( "a modal swing jdialog parent null.", joptionpane.information_message); final jdialog dialog = optionpane.createdialog(null, "jdialog parent null.");
in class implements awteventlistener
there handleopenedwindow
method:
private void handleopenedwindow(windowevent event) { final window window = event.getwindow(); if (window instanceof dialog) { if (window.getparent() == null || window.getparent().getclass().getname() .contains("sharedownerframe")) { updatewindowlocation(window); } } }
as alternative tried use window.getowner().getclass().isassignablefrom(javax.swing.swingutilities.class)
not working.
what more elegant way check if jdialog
has no parent?
update
swingutilities.windowforcomponent(window)
evaluates @ runtime as:
javax.swing.swingutilities$sharedownerframe[frame0,0,0,132x38,invalid,hidden,layout=java.awt.borderlayout,title=,resizable,normal]
Comments
Post a Comment