Here you can find the source of getParentJFrame(Container theFrame)
Parameter | Description |
---|---|
theFrame | the container whose parent is sought |
public static JFrame getParentJFrame(Container theFrame)
//package com.java2s; // This software is licensed under the GNU General Public License, import java.awt.Container; import javax.swing.JFrame; public class Main { /**// w w w .j av a2 s . c o m * finds a parent JFrame for the specified container. If none is found it invents one. Useful for creating new * dialogs that insist on having a parent * * @param theFrame * the container whose parent is sought * @return the parent JFrame of the container */ public static JFrame getParentJFrame(Container theFrame) { do { theFrame = theFrame.getParent(); } while ((theFrame != null) && !(theFrame instanceof JFrame)); if (theFrame == null) theFrame = new JFrame(); return (JFrame) theFrame; } }