FileDocCategorySizeDatePackage
OpaqueExample.javaAPI DocExample1309Thu Oct 24 20:14:22 BST 2002None

OpaqueExample

public class OpaqueExample extends JFrame

Fields Summary
Constructors Summary
public OpaqueExample()

    super("Opaque JPanel Demo");
    setSize(400, 200);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel opaque = createNested(true);
    JPanel notOpaque = createNested(false);

    // Throw it all together
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(opaque);
    getContentPane().add(notOpaque);
  
Methods Summary
public javax.swing.JPanelcreateNested(boolean opaque)

    JPanel outer = new JPanel(new FlowLayout());
    JPanel inner = new JPanel(new FlowLayout());
    outer.setBackground(Color.white);
    inner.setBackground(Color.black);

    inner.setOpaque(opaque);
    inner.setBorder(BorderFactory.createLineBorder(Color.gray));

    inner.add(new JButton("Button"));
    outer.add(inner);

    return outer;
  
public static voidmain(java.lang.String[] args)

    OpaqueExample oe = new OpaqueExample();
    oe.setVisible(true);