Java JFrame Parent getParentFrame(JComponent comp)

Here you can find the source of getParentFrame(JComponent comp)

Description

Finds the parent frame of the component or null if there isn't one

License

Open Source License

Declaration

public static JFrame getParentFrame(JComponent comp) 

Method Source Code

//package com.java2s;
// modify it under the terms of the GNU General Public License version 2

import javax.swing.*;

import java.awt.*;

public class Main {
    /**/*from  ww w. j a  v  a2 s.  c  om*/
     * Finds the parent frame of the component or null if there isn't one
     */
    public static JFrame getParentFrame(JComponent comp) {
        Component p = comp.getParent();
        while (p != null) {
            if (p instanceof JFrame)
                return (JFrame) p;
            else
                p = p.getParent();
        }
        return null;
    }
}

Related

  1. getParentFrame(Component component)
  2. getParentFrame(Component parent)
  3. getParentFrame(Component source)
  4. getParentFrame(Frame[] parentFrames)
  5. getParentFrame(JComponent c)
  6. getParentFrame(JComponent comp)
  7. getParentFrameForCompomponent(Component comp)
  8. getParentInternalFrame(Component comp)
  9. getRealFrameParent(Component c)