Here you can find the source of getRootJFrame(Component c)
Parameter | Description |
---|---|
c | a Component |
public static javax.swing.JFrame getRootJFrame(Component c)
//package com.java2s; import java.awt.*; public class Main { /**//from w w w . j a va2s .c o m * This is the only method that relies on Swing. Comment this one out and * this class is AWT-only capable. * * @param c a Component * @return the JFrame containing the component or null if the component * doesn't have a containing JFrame. */ public static javax.swing.JFrame getRootJFrame(Component c) { Object parent = c.getParent(); while (parent != null) { if (parent instanceof javax.swing.JFrame) return (javax.swing.JFrame) parent; parent = ((Component) parent).getParent(); } return null; } }