Java tutorial
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MainClass { public static void main(String[] args) { JFrame f = new JFrame(); final JPanel p1 = new JPanel(); p1.add(new JLabel("GlassPane Example")); JButton show = new JButton("Show"); p1.add(show); p1.add(new JButton("No-op")); f.getContentPane().add(p1); final JPanel glass = (JPanel) f.getGlassPane(); glass.setVisible(true); glass.setLayout(new GridBagLayout()); JButton glassButton = new JButton("Hide"); glass.add(glassButton); f.setSize(150, 80); f.setVisible(true); show.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { glass.setVisible(true); p1.repaint(); } }); glassButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { glass.setVisible(false); p1.repaint(); } }); } }