?? studentframe.java
字號:
package edu.sm.view;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Choice;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.text.SimpleDateFormat;
import edu.sm.model.Student;
import edu.sm.view.event.MainClosingAction;
public abstract class StudentFrame extends BaseFrame {
/**
* 修改或添加學生
*/
protected Student student;
/**
* 確認按鈕
*/
protected Button ok;
/**
* 取消按鈕
*/
protected Button cancal;
/**
* 選擇班級
*/
protected Choice classes;
/**
* 姓名
*/
protected TextField name;
/**
* 選擇性別
*/
protected Choice sex;
/**
* 出生日期
*/
protected TextField birth;
/**
* 入學時間
*/
protected TextField inTime;
/**
* 日期轉換
*/
protected SimpleDateFormat sdf;
public StudentFrame(String title, Student student) {
super(title, 100, 100, 300, 500);
this.sdf = new SimpleDateFormat("yyyy-MM-dd");
this.student = student;
this.addWindowListener(new MainClosingAction("確認關閉?","關閉不會造成保存和更新,填入的數據將丟失,是否關閉?",false,this));
this.setLayout(new GridLayout(1,2));
Panel p1 = new Panel();
Panel p2 = new Panel();
Label name1 = new Label("所在班級");
classes = new Choice();
classes.add("無班級");
//TODO 讀出所有班級
Panel t1 = new Panel();
t1.setLayout(new FlowLayout(FlowLayout.CENTER));
t1.add(name1);
t1.add(classes);
Label name2 = new Label("學生姓名");
name = new TextField(10);
Panel t2 = new Panel();
t2.setLayout(new FlowLayout(FlowLayout.CENTER));
t2.add(name2);
t2.add(name);
Label name3 = new Label("性別");
sex = new Choice();
sex.add("男");
sex.add("女");
Panel t3 = new Panel();
t3.setLayout(new FlowLayout(FlowLayout.CENTER));
t3.add(name3);
t3.add(sex);
Label name4 = new Label("出生年月(YYYY-MM-DD)");
birth = new TextField(10);
Panel t4 = new Panel();
t4.setLayout(new FlowLayout(FlowLayout.CENTER));
t4.add(name4);
t4.add(birth);
Label name5 = new Label("入學時間(YYYY-MM-DD)");
Panel t5 = new Panel();
inTime = new TextField(10);
t5.setLayout(new FlowLayout(FlowLayout.CENTER));
t5.add(name5);
t5.add(inTime);
p1.setLayout(new GridLayout(5,1));
p1.add(t1);
p1.add(t2);
p1.add(t3);
p1.add(t4);
p1.add(t5);
p2.setLayout(new FlowLayout(FlowLayout.CENTER));
ok = new Button("確定");
cancal = new Button("取消");
p2.add(ok);
p2.add(cancal);
this.setLayout(new BorderLayout());
this.add(BorderLayout.CENTER,p1);
this.add(BorderLayout.SOUTH,p2);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -