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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -