import java.awt.*;(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
import java.applet.*;
public class NestedPanels extends Applet
{
protected Choice choice;
protected Button b;
protected Label messageBox;
public NestedPanels()
{
Panel center=new Panel();
center.setLayout(new BorderLayout());
center.add(new Button("North"),BorderLayout.NORTH);
center.add(new Button("South"),BorderLayout.SOUTH);
center.add(new Button("West"),BorderLayout.WEST);
centre.add(new Button("East"),BorderLayout.EAST);
center.add(new Button("Center"),BorderLayout.CENTER);
Panel south=new Panel();
south.setLayout(new FlowLayout());
b=new Button("Help");
south.add(b);
choice=new Choice();
choice.addItem("one");
choice.addItem("two");
choice.addItem("three");
choice.addItem("four");
choice.addItem("five");
south.add(choice);
messageBox=new Label("This is a message bar.");
south.add(messageBox);
setLayout(new BorderLayout());
add(new Button("North"),BorderLayout.NORTH);
add(new Button("West"),BorderLayout.WSET);
add(new Button("East"),BorderLayout.EAST);
add(south,BorderLayout.SOUTH);
add(center,BorderLayout.CENTER);
}
}