网格GridLayout建立

import java.awt.*;
public class GridFlowout extends Frame {
public GridFlowout (String str){
{setTitle(str);
setBackground(Color.cyan);
setLocation(100, 100);
setLayout(new GridLayout(4,4));
setSize(800, 600);
Button bt[]=new Button[10];
for(int i=0;i<bt.length;i++)
{bt[i]=new Button("按钮"+i);
add(bt[i]);}

Panel f=new Panel();
f.setLayout(new FlowLayout());
f.setBackground(new Color(150,100,0));
f.add(new Button("Ok"));
f.add(new TextField(20));
f.add(new Label("name"));
add(f,2);
setVisible(true);
}
}

public static void main(String[] args) {
new GridFlowout("湖南城市学院");
}
}








 

posted @ 2016-06-21 14:06  折腾青春  阅读(102)  评论(0编辑  收藏  举报