Java JComponent Container rootPaneForComponent(Component comp)

Here you can find the source of rootPaneForComponent(Component comp)

Description

root Pane For Component

License

Apache License

Declaration

public static JRootPane rootPaneForComponent(Component comp) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Component;

import javax.swing.JDialog;
import javax.swing.JFrame;

import javax.swing.JRootPane;
import javax.swing.JWindow;

public class Main {
    public static JRootPane rootPaneForComponent(Component comp) {
        for (Component p = comp; p != null; p = p.getParent()) {
            if (p instanceof JRootPane) {
                return (JRootPane) p;
            }//  w  w  w .j a  v  a 2s  .  c o m

            if (comp instanceof JFrame) {
                return ((JFrame) comp).getRootPane();
            }

            if (comp instanceof JDialog) {
                return ((JDialog) comp).getRootPane();
            }

            if (comp instanceof JWindow) {
                return ((JWindow) comp).getRootPane();
            }
        }

        return null;
    }
}

Related

  1. getWindow(JComponent c)
  2. getWindowLocation(JComponent start)
  3. invokeRepaintOnLayeredRoot(Component leaf, boolean everything)
  4. isCopyEnabled(JComponent targetComponent)
  5. isPasteEnabled(JComponent targetComponent)
  6. widgetsEnable(boolean flag, JComponent... comps)