当前位置:文档之家› 山东科技大学-Java数据结构实验六

山东科技大学-Java数据结构实验六

if("登录成功!".equals(result)){
JOptionPane.showMessageDialog(frame,result);
StudentMainViewindex=newStudentMainView(stu);
JFrameframe2=index.getFrame();
frame2.setVisible(true);
lblNewLabel_1.setFont(newFont("宋体", Font.PLAIN, 14));
lblNewLabel_1.setBounds(87, 67, 67, 15);
frame.getContentPane().add(lblNewLabel_1);
textField=newJTextField();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabellblNewLabel=newJLabel("\u5B66\u751F\u6210\u7EE9\u7BA1\u7406\u7CFB\u7EDF\u7528\u6237\u767B\u5F55\uFF01");
for(Objectob:objs){
// JOptionPane.showMessageDialog(frame, ob.toString());
if("高等数学".equals(ob.toString())){
textField_2.setText("高等数学");
textField_3.setText("98");
}
publicString getIdentify() {
returnidentify;
}
publicvoidsetIdentify(Stringidentify) {
this.identify=identify;
}
(2)测试的结果和显示
frame.setIconImage(Toolkit.getDefaultToolkit().getImage(MainUI.class.getResource("/image/func_list7_privmana.png"))));
returnname;
}
publicvoidsetName(Stringname) {
=name;
}
publicintgetPassword() {
returnpassword;
}
publicvoidsetPassword(intpassword) {
this.password=password;
lblNewLabel_2.setBounds(105, 150, 97, 15);
frame.getContentPane().add(lblNewLabel_2);
finalChoicechoice=newChoice();
choice.setBounds(210, 147, 74, 21);
choice.add("学生");
choice.add("教师");
choice.add("系统管理员");
frame.getContentPane().add(choice);
Buttonbutton=newButton("\u767B\u5F55");
button.setBounds(87, 194, 76, 23);
button.addMouseListener(newMouseAdapter() {
this.idnum=idnum;
this.password=password;
this.identify=identify;
}
publicintgetIdnum() {
returnidnum;
}
publicvoidsetIdnum(intidnum) {
this.idnum=idnum;
}
publicString getName() {
熟练使用Java AWT或SWING类库中的容器、组件及事件响应机制开发图形化桌面应用程序。
二、实验内容
1.使用Java设计实现一个带有GUI界面的学生成绩管理系统。基本功能包括:
1)增添、删除、修改学生基本信息:学号、姓名、出生日期、专业课程分数;
2)计算每门课的平均成绩;
3)统计优秀、良好、中等、及格、不及格的人数百分比,并以柱状图、饼图呈现【说明:可以使用SWING、AWT自己绘制;也可以使用开源类库,如JFreeChar】
label.setBounds(87, 108, 67, 15);
frame.getContentPane().add(label);
textField_1=newJTextField();
textField_1.setColumns(10);
textField_1.setBounds(154, 103, 141, 21);
@Override
publicvoidmouseClicked(MouseEvente) {
Stringuser=textField.getText();
Stringpassword=textField_1.getText();
Stringshenfen=choice.getSelectedItem();
textField.setBounds(154, 64, 141, 21);
frame.getContentPane().add(textField);
textField.setColumns(10);
JLabellabel=newJLabel("\u5BC6 \u7801\uFF1A");
label.setFont(newFont("宋体", Font.PLAIN, 14));
frame.getContentPane().add(textField_1);
JLabellblNewLabel_2=newJLabel("\u6211\u7684\u8EAB\u4EFD\u662F\uFF1A");
lblNewLabel_2.setFont(newFont("宋体", Font.PLAIN, 14));
熟练使用javaawtswing类库中的容器组件及事件响应机制开发图形化桌面应用程序
实验 报 告
课程名称:
学院:
专业:班级:
姓名:学号:
年月日
山东科 技大学教务处 制
实验报告

组别
姓名
同组实验者
实验项目
名称
实验日期
教师评语
实验成绩:
指导教师(签名):
年月日
一、实验目标
掌握Java GUI开发的基本原理。
frame.dispose();
}else{
JOptionPane.showMessageDialog(frame,result);
}
成绩内容设置:通过else if语句进行判断。
publicvoiditemStateChanged(ItemEvente) {
Object[]objs=e.getItemSelectable().getSelectedObjects();
}elseif("大学英语".equals(ob.toString())){
textField_2.setText("大学英语");
textField_3.setText("87");
}elseif("马列主义".equals(ob.toString())){
textField_2.setText("马列主义");
textField_2.setText("计算机图形学");
textField_3.setText("97");
}
}
学生登录:通过密码和用户名进入系统,通过this指针进行判断。
publicStudentInfo(intidnum,intpassword, Stringidentify) {
super();
if(user.equals("")||user==null){
JOptionPane.showMessageDialog(frame,shenfen+":您好,帐号不能为空!");
return;
}elseif(password.equals("")||password==null){
JOptionPane.showMessageDialog(frame,shenfen+":您好,密码不能为空!");
4)按学号查询学生及成绩;
5)按照成绩分数排序;
6)提供数据存储功能(不使用数据库,全部使用流操作文件完成)。
三、实验步骤和结果
(1)文字分析和代码详情
登录界面的设置:设置密码进行验证。
privatevoidinitialize() {
frame=newJFrame();
frame.setTitle("\u6210\u7EE9\u7BA1\u7406\u7CFB\u7EDF\uFF08\u767B\u5F55\uFF09");
lblNewLabel.setFont(newFont("宋体", Font.PLAIN, 16));
相关主题