Here you can find the source of findParentDialogOrFrame(Container container)
Parameter | Description |
---|---|
container | The container to start looking for a JDialog or JFrame in the parent hierarchy. |
null
if none was found.
public static Object findParentDialogOrFrame(Container container)
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { /**/*from w w w . j a v a2 s .co m*/ * Look for a JDialog or JFrame in the parent hierarchy of this specified container * and return that JDialog or JFrame. If none is found the method returns <code>null</code>. * * @param container The container to start looking for a JDialog or JFrame in the parent hierarchy. * @return The JDialog or JFrame found or <code>null</code> if none was found. */ public static Object findParentDialogOrFrame(Container container) { while (container != null) { if (container instanceof JFrame || container instanceof JDialog) { return container; } container = container.getParent(); } return null; } }