Here you can find the source of getGlassPane(JComponent comp)
public static Component getGlassPane(JComponent comp)
//package com.java2s; //License from project: LGPL import java.awt.Component; import java.awt.Container; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFrame; public class Main { public static Component getGlassPane(JComponent comp) { Container container = comp.getTopLevelAncestor(); if (container instanceof JFrame) { JFrame frame = (JFrame) container; return frame.getGlassPane(); } else if (container instanceof JDialog) { JDialog dialog = (JDialog) container; return dialog.getGlassPane(); } else {/*from ww w . j ava 2 s.com*/ throw new RuntimeException("unsupported top level ancestor!"); } } }