// Create 2 JPanels (opaque), one containing another opaque JPanel, and
// the other containing a nonopaque JPanel
JPanel opaque = createNested(true);
JPanel notOpaque = createNested(false);
// Throw it all together in a JFrame
JFrame f = new JFrame();
f.addWindowListener(new BasicWindowMonitor());
f.getContentPane().setLayout(new FlowLayout());
f.getContentPane().add(opaque);
f.getContentPane().add(notOpaque);
f.pack();
f.setVisible(true);