// package SwingDemos; import java.awt.*; import javax.swing.*; /** * ComponentNester.java * * * Created: Mon Mar 17 11:33:48 2003 * * @author <a href="mailto:shapiro@cse.buffalo.edu">Stuart C. Shapiro</a> */ public class ComponentNester { public ComponentNester (Container pane){ pane.setBackground(Color.blue); JComponent first = new JPanel(); first.setBounds(200, 200, 250, 350); first.setBackground(Color.green); pane.add(first); JComponent second = new JPanel(); second.setBounds(25, 25, 200, 300); second.setBackground(Color.white); first.add(second); JComponent third = new JPanel(); third.setBounds(25, 25, 150, 250); third.setBackground(Color.red); second.add(third); JComponent fourth = new JPanel(); fourth.setBounds(25, 25, 100, 200); fourth.setBackground(Color.yellow); third.add(fourth); JComponent fifth = new JPanel(); fifth.setBounds(25, 25, 50, 150); fifth.setBackground(Color.black); fourth.add(fifth); } }// ComponentNester