您的位置:首页 > 其它

CCNA学习有感,认识cisco认证体系

2007-09-07 11:05 211 查看
范例2-flowlayout
一:
import java.awt.*;
import java.awt.event.*;
public class flowlayout
{
Frame myf;
Button b1,b2,b3,b4,b5,b6;
public static void main(String args[])
{
flowlayout myfl=new flowlayout();
myfl.init();
}
public void init()
{
myf=new Frame();
myf.setLayout(new FlowLayout(FlowLayout.LEFT,20,40));
myf.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
b1=new Button("b1");
b2=new Button("b2");
b3=new Button("b3");
b4=new Button("b4");
b5=new Button("b5");
b6=new Button("b6");
myf.add(b1);
myf.add(b2);
myf.add(b3);
myf.add(b4);
myf.add(b5);
myf.add(b6);
myf.setSize(100,100);

myf.setVisible(true);
}
}

二.
import java.awt.*;
import java.awt.event.*;
public class flowlayout
{

public static void main(String args[])
{
Frame myf;
Button b1,b2,b3,b4,b5,b6;

myf=new Frame();
myf.setLayout(new FlowLayout(FlowLayout.LEFT,20,40));
myf.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
b1=new Button("b1");
b2=new Button("b2");
b3=new Button("b3");
b4=new Button("b4");
b5=new Button("b5");
b6=new Button("b6");
myf.add(b1);
myf.add(b2);
myf.add(b3);
myf.add(b4);
myf.add(b5);
myf.add(b6);

myf.setSize(100,100);

myf.setVisible(true);
}
}

//组件按照加入的先后顺序从左向右排列,一行排列满以后就会自动转到下一行,且每一行的组件都居中排列,
//FlowLayout的属性:CENTER,LEFT,RIGHT,
//FlowLayout的三个构造函数 1.FlowLayout();FlowLayout(int align):FlowLayout(int align,int hgap,int vgap)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: