get新技能是需要付出行动的,即使看得再多也还是要动手试一试。今天图老师小编跟大家分享的是BorderLayout的简介,一起来学习了解下吧!
【 tulaoshi.com - 编程语言 】
import java.awt.*;(本文来源于图老师网站,更多请访问http://www.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);
}
}
来源:http://www.tulaoshi.com/n/20160219/1609904.html
看过《BorderLayout的简介》的人还看了以下文章 更多>>