2019级计算机系所有学生的信息存放在student_score.txt文件中, 为了方便管理学生信息,需要设计一个GUI图形化程序,功能如下:
• 1.统计出各班学生的人数并在界面上显示。
• 2.完成基于班级的模糊查询。
• 3.完成基于学号的精确查询。
public StudentInfoManageSystem(String title) {
super(title);
//窗体属性
setSize(800, 500);
setVisible(true);
setLayout(new GridLayout(2,1));
//文本
text1 = new TextField("输入班级或学号", 20);
//文本域
textarea1 = new TextArea("");
//按钮
button1 = new Button("查询各班人数");
button1.setActionCommand("1"); //设置组件行动命令(暗号)
button1.addActionListener(this);
button2 = new Button("基于班级模糊查询");
button2.setActionCommand("2"); //设置组件行动命令(暗号)
button2.addActionListener(this);
button3 = new Button("基于学号精准查询");
button3.setActionCommand("3"); //设置组件行动命令(暗号)
button3.addActionListener(this);
//P1面板
// panel1.add(text1, BorderLayout.WEST);
// panel1.add(textarea1, BorderLayout.EAST);
panel1.add(text1);
panel1.add(textarea1);
//P2面板
panel2.add(button1, BorderLayout.EAST);
panel2.add(button2, BorderLayout.CENTER);
panel2.add(button3, BorderLayout.WEST);
add(panel1);
add(panel2);
// //让打开的窗口可以关闭
addWindowListener(new WindowAdapter() {//增加监听器 适配模式
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
setVisible(true);
}