网格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("湖南城市学院");
}
}