Java JFrame Parent findParentDialogOrFrame(Container container)

Here you can find the source of findParentDialogOrFrame(Container container)

Description

Look for a JDialog or JFrame in the parent hierarchy of this specified container and return that JDialog or JFrame.

License

Open Source License

Parameter

Parameter Description
container The container to start looking for a JDialog or JFrame in the parent hierarchy.

Return

The JDialog or JFrame found or null if none was found.

Declaration

public static Object findParentDialogOrFrame(Container container) 

Method Source Code


//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;
    }
}

Related

  1. enableAllComponents(final boolean enable, final Frame parent)
  2. enableAllComponentsExcept(final boolean enable, final Frame parent, final Component... components)
  3. ensureVisibilityAtParent(final JInternalFrame frame)
  4. execLoop(JComponent editor, Frame parent, boolean modal, int w, int h)
  5. fileOpen(Frame parent, String typename, String ext)
  6. getFirstParentFrameOrDialog(Component cmp)
  7. getFrame(Component parent)
  8. getFrameParent(Component component)
  9. getInstalledOperation(final RootPaneContainer frame, final Object actionKey, boolean selfOnly)