⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentframe.java

📁 学生管理系统
💻 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 + -