Here you can find the source of getRootPane(Window window)
public static JRootPane getRootPane(Window window)
//package com.java2s; //License from project: Apache License import java.awt.Window; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JRootPane; public class Main { public static JRootPane getRootPane(Window window) { if (window instanceof JFrame) { return ((JFrame) window).getRootPane(); }//from w ww. j ava 2s . c om if (window instanceof JDialog) { return ((JDialog) window).getRootPane(); } return null; } }