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