SwingUtilities: getWindowAncestor(Component c)
import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class Main { public static void main(String[] a) { JPanel panel = new JPanel(); JDialog dialog = new JDialog((JFrame) SwingUtilities.getWindowAncestor(panel), true); } }