I have a mainFrame with a custom class loader. My loader is loading Pannels in the mainFrame as needed. In one of the pannel i have a JDialog. I want the JDialog box to blocks all windows from the application.
in the pannel i would like to do somting like this.
myDialog = new JDialog(getSelectedFrame(),"",Dialog.ModalityType...);
Thanks!
You dont’ need it. If you want to parent the dialog to a frame, dialog, or whatever you can simply call getTopLevelAncestor() on the component that is instantiating the JDialog. That makes knowing the frame irrelevant which helps ensure the person calling or reusing code can use it on any component: frame, another dialog, window, etc.
http://docs.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#getTopLevelAncestor()
For example:
Now by using MySpecialPanel.getTopLevelAncestor() the dialog you are creating doesn’t need to know the exact component it is. And the client using MySpecialPanel is free to put this panel into any container it desires be that a JFrame, another JDialog, or whatever.