Example usage for javax.swing JRootPane getLayeredPane

List of usage examples for javax.swing JRootPane getLayeredPane

Introduction

In this page you can find the example usage for javax.swing JRootPane getLayeredPane.

Prototype

public JLayeredPane getLayeredPane() 

Source Link

Document

Gets the layered pane used by the root pane.

Usage

From source file:Main.java

/**
 * Returns layered pane for the specified component or null if it doesn't exist.
 *
 * @param component component to look under
 * @return layered pane for the specified component or null if it doesn't exist
 *///from  ww  w . j a  v a  2s .  c  o  m
public static JLayeredPane getLayeredPane(final Component component) {
    final JRootPane rootPane = getRootPane(component);
    return rootPane != null ? rootPane.getLayeredPane() : null;
}

From source file:Main.java

/**
 * Gets the layered pane of the window of the given component.
 * The window of the root pane should be a javax.swing.JFrame, javax.swing.JDialog
 * or javax.swing.JWindow. Otherwise the layered pane of the rootpane is returned.
 * // ww  w  . j  a  v a  2  s  .  c om
 * @param    rootPane      The root pane whose layered pane is retrieved.
 * @return                The layered pane.
 */
public static JLayeredPane getLayeredPane(JRootPane rootPane) {

    // Get the window of the component.
    Window window = SwingUtilities.getWindowAncestor(rootPane);
    if (window != null) {
        // Get the layered pane if we can find one.
        if (window instanceof JFrame)
            return ((JFrame) window).getLayeredPane();
        if (window instanceof JDialog)
            return ((JDialog) window).getLayeredPane();
        if (window instanceof JWindow)
            return ((JWindow) window).getLayeredPane();
    }

    // Get the layered pane of the root pane immediately.
    return rootPane.getLayeredPane();

}