📄 frame_markchange.java
字号:
jLabel_inf1.setText("姓名:" + s.students[n].name + " 性别:"
+ s.students[n].sex + " 班级:" + s.students[n].classNo + " 学号:" + s.students[n].id);
this.setSize(500, 500);
jButton1.setBounds(new Rectangle(8, 420, 480, 40));
jScrollPane1.setVisible(true);
int lines = 0;
int num = 0;//各学期课程数
for(int tearm=0;tearm<4;tearm++)
//while(s.students[n].inf_tearm[tearm].sub[num]!=null)
for(num=0;num<s.students[n].inf_tearm[tearm].num;num++){
jTable1.setValueAt("第"+(tearm+1)+"学期",lines,0);
jTable1.setValueAt(s.students[n].inf_tearm[tearm].sub[num],lines,1);
jTable1.setValueAt(new Integer(s.students[n].inf_tearm[tearm].sub_mark[num]),lines,2);
lines++;
System.out.print(tearm + " " + lines +"\n");
//num++;
}
}
else {
nofound.setVisible(true);
jLabel_inf_title.setVisible(false);
jLabel_inf1.setVisible(false);
this.setSize(500,200);
jButton1.setBounds(new Rectangle(8, 120, 480, 40));
}
}
public void jButton_cok_actionPerformed(ActionEvent e) {
boolean recourse = false;//课程重复
String newcourse = jTextField2.getText();
int newmark = Integer.parseInt(jTextField3.getText());
int newtearm = jCombotearm.getSelectedIndex();
int tearmw=0;
int coursew=0;//记录修改的学期数和课程数
if(!newcourse.equals("")){
for(int i=0;i<4;i++)
for(int j=0;j<s.students[n].inf_tearm[i].num;j++)
if(newcourse.equals(s.students[n].inf_tearm[i].sub[j])){
recourse = true;
tearmw = i;
coursew = j;
break;
}
if(recourse){//输入的课程已存在
//修改成绩
/*for(int i=0;i<s.students[n].inf_tearm[tearmw].num;i++){
s.students[n].inf_tearm[tearmw].sub[coursew] = s.students[n].inf_tearm[tearmw].sub[coursew+1];
s.students[n].inf_tearm[tearmw].sub_mark[coursew] = s.students[n].inf_tearm[tearmw].sub_mark[coursew+1];
s.students[n].inf_tearm[tearmw].num--;
}
s.students[n].inf_tearm[newtearm].sub[s.students[n].inf_tearm[tearmw].num] = newcourse;
s.students[n].inf_tearm[newtearm].sub_mark[s.students[n].inf_tearm[tearmw].num] = newmark;
s.students[n].inf_tearm[tearmw].num++;*/
s.students[n].change_inftearm(newtearm,newcourse,newmark);
nofounddel.setVisible(true);
nofounddel.setText("成功!");
s.writedata();
//显示在表格上
int lines = 0;
int num = 0;//各学期课程数
for(int tearm=0;tearm<4;tearm++)
//while(s.students[n].inf_tearm[tearm].sub[num]!=null)
for(num=0;num<s.students[n].inf_tearm[tearm].num;num++){
jTable1.setValueAt("第"+(tearm+1)+"学期",lines,0);
jTable1.setValueAt(s.students[n].inf_tearm[tearm].sub[num],lines,1);
jTable1.setValueAt(new Integer(s.students[n].inf_tearm[tearm].sub_mark[num]),lines,2);
lines++;
System.out.print(tearm + " " + lines +" " +num+"\n");
//num++;
}
}
else{//输入的课程不存在,即添加新的
/*s.students[n].inf_tearm[newtearm].sub[s.students[n].inf_tearm[tearmw].num] = newcourse;
s.students[n].inf_tearm[newtearm].sub_mark[s.students[n].inf_tearm[tearmw].num] = newmark;
s.students[n].inf_tearm[tearmw].num++;*/
s.students[n].inf_tearm[newtearm].add(newcourse,newmark);
nofounddel.setVisible(true);
nofounddel.setText("成功!");
s.writedata();
//显示在表格上
int lines = 0;
int num = 0;//各学期课程数
for(int i=0;i<50;i++)
for(int j=0;j<3;j++)
jTable1.setValueAt(null,i,j);//初始化表格
for(int tearm=0;tearm<4;tearm++)
//while(s.students[n].inf_tearm[tearm].sub[num]!=null)
for(num=0;num<s.students[n].inf_tearm[tearm].num;num++){
jTable1.setValueAt("第"+(tearm+1)+"学期",lines,0);
jTable1.setValueAt(s.students[n].inf_tearm[tearm].sub[num],lines,1);
jTable1.setValueAt(new Integer(s.students[n].inf_tearm[tearm].sub_mark[num]),lines,2);
lines++;
System.out.print(tearm + " " + lines +"\n");
//num++;
}
}
}
else{
nofounddel.setVisible(true);
nofounddel.setText("课程不能为空!");
}
}
public void jButton_delc_actionPerformed(ActionEvent e) {
//删除一门课
String newcourse = jTextField2.getText();
int newmark = Integer.parseInt(jTextField3.getText());
int newtearm = jCombotearm.getSelectedIndex();
int tearmw=0;
int coursew=0;//记录修改的学期数和课程数
boolean recourse = false;//课程重复
if(!newcourse.equals("")){
for(int i=0;i<4;i++)
for(int j=0;j<s.students[n].inf_tearm[i].num;j++)
if(newcourse.equals(s.students[n].inf_tearm[i].sub[j])){
recourse = true;
tearmw = i;
coursew = j;
break;
}
if(recourse){
/*for(int i=0;i<s.students[n].inf_tearm[tearmw].num;i++){
s.students[n].inf_tearm[tearmw].sub[coursew] = s.students[n].inf_tearm[tearmw].sub[coursew+1];
s.students[n].inf_tearm[tearmw].sub_mark[coursew] = s.students[n].inf_tearm[tearmw].sub_mark[coursew+1];
s.students[n].inf_tearm[tearmw].num--;
}*/
s.students[n].inf_tearm[tearmw].delete(newcourse);
nofounddel.setVisible(true);
nofounddel.setText("删除成功!");
s.writedata();
//显示在表格上
for(int i=0;i<50;i++)
for(int j=0;j<3;j++)
jTable1.setValueAt(null,i,j);//初始化表格
int lines = 0;
int num = 0;//各学期课程数
for(int tearm=0;tearm<4;tearm++)
//while(s.students[n].inf_tearm[tearm].sub[num]!=null)
for(num=0;num<s.students[n].inf_tearm[tearm].num;num++){
jTable1.setValueAt("第"+(tearm+1)+"学期",lines,0);
jTable1.setValueAt(s.students[n].inf_tearm[tearm].sub[num],lines,1);
jTable1.setValueAt(new Integer(s.students[n].inf_tearm[tearm].sub_mark[num]),lines,2);
lines++;
//System.out.print(tearm + " " + lines +"\n");
//num++;
}
}
else{
nofounddel.setVisible(true);
nofounddel.setText("没有这门课!");
//s.writedata();
}
}
}
}
class Frame_markchange_jButton_delc_actionAdapter implements ActionListener {
private Frame_markchange adaptee;
Frame_markchange_jButton_delc_actionAdapter(Frame_markchange adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton_delc_actionPerformed(e);
}
}
class Frame_markchange_jButton_cok_actionAdapter implements ActionListener {
private Frame_markchange adaptee;
Frame_markchange_jButton_cok_actionAdapter(Frame_markchange adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton_cok_actionPerformed(e);
}
}
class Frame_markchange_jButton_OK0_actionAdapter implements ActionListener {
private Frame_markchange adaptee;
Frame_markchange_jButton_OK0_actionAdapter(Frame_markchange adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton_OK0_actionPerformed(e);
}
}
class Frame_markchange_jComboBox1_actionAdapter implements ActionListener {
private Frame_markchange adaptee;
Frame_markchange_jComboBox1_actionAdapter(Frame_markchange adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jComboBox1_actionPerformed(e);
}
}
class Frame_markchange_jButton1_actionAdapter implements ActionListener {
private Frame_markchange adaptee;
Frame_markchange_jButton1_actionAdapter(Frame_markchange adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -