Java JFrame Parent getParentalFrame(Component n)

Here you can find the source of getParentalFrame(Component n)

Description

Get the Frame a Component is contained in.

License

Open Source License

Return

the first parent frame or null if none.

Declaration

public static Frame getParentalFrame(Component n) 

Method Source Code


//package com.java2s;
import java.awt.Component;

import java.awt.Frame;

public class Main {
    /**//from w w w.j a  v  a2 s  .  com
     * Get the Frame a Component is contained in.
     * <p>
     * Traverses parents until a Frame is found.
     * @return the first parent frame or <code>null</code> if none.
     * @deprecated Use {@link javax.swing.SwingUtilities#getAncestorOfClass(Class, Component) SwingUtilities.getAncestorOfClass(Frame.class, n)} instead.
     * @see javax.swing.SwingUtilities#getAncestorOfClass(Class, Component)
     */
    public static Frame getParentalFrame(Component n) {
        while (!(n instanceof Frame) && n != null)
            n = n.getParent();
        return (Frame) n;
    }
}

Related

  1. findParentDialogOrFrame(Container container)
  2. getFirstParentFrameOrDialog(Component cmp)
  3. getFrame(Component parent)
  4. getFrameParent(Component component)
  5. getInstalledOperation(final RootPaneContainer frame, final Object actionKey, boolean selfOnly)
  6. getParentFrame(Component component)
  7. getParentFrame(Component component)
  8. getParentFrame(Component parent)
  9. getParentFrame(Component source)