Layering multiple GlassPane’s in a Root Container

Look at http://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html for an explanation on Root panes and what the Glass pane actually is.

The glass pane is just a convenient way to add a component which has the size of the Root Pane, and which blocks all input events. This allows you to catch any interaction with your components to create a “Please wait…” screen.

There is only a single glass pane per root container. You cannot layer glass panes.

You can replace the contents of the glass pane by something else if you want to layer something over the current glass pane. You can also set a JPanel as a glass pane, which allows you to layout multiple components in the glass pane.

Usually, you should only use the glass pane to block user input (and, if necessary, display some kind of “please wait” message). Can you provide a use case of why you want to put glass panes on top of one another?

Leave a Comment