?? gridlayoutexam.java
字號:
package ch7;
import java.awt.*;
public class GridLayoutExam extends Frame
{
String [] mark={"身份證號","姓名","別名","性別","出生年月","出生地","學(xué)號","成績","備注"};
TextField [] text; //聲明文本框數(shù)組輸入各項信息
Button bt1,bt2; //聲明兩個按鈕
public GridLayoutExam()
{
setTitle("GridLayout布局示例");
setLayout(new GridLayout(0,6)); //設(shè)置網(wǎng)格布局,每行6列,行數(shù)不定
setSize(400,150); //設(shè)置容器的大小
text=new TextField[mark.length]; //定義文本框數(shù)組的大小
for(int i=0;i<mark.length;i++)
{
text[i]=new TextField(); //創(chuàng)建每個文本框?qū)ο? add(new Label(mark[i])); //將每個標簽加入容器
add(text[i]); //將每個文本框加入容器
}
bt1=new Button("重置"); //創(chuàng)建按鈕對象bt1
bt2=new Button("提交"); //創(chuàng)建按鈕對象bt2
add(new Label()); //為了按鈕的擺放位置,添加一個空標簽
add(bt1); //將按鈕bt1加入容器
add(new Label()); // 添加一個空標簽
add(bt2); //將按鈕bt2加入容器
setVisible(true);
}
public static void main(String args[])
{
new GridLayoutExam();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -