📄 stumsjframe.java
字号:
menuStuInquiry.add(itemInquiryBySname); itemInquiryBySsex.setText("按性别查询"); menuStuInquiry.add(itemInquiryBySsex); itemInquiryByScollege.setText("按学院查询"); menuStuInquiry.add(itemInquiryByScollege); itemInquiryBySspecialSubject.setText("按专业查询"); menuStuInquiry.add(itemInquiryBySspecialSubject); menuInformationInquiry.add(menuStuInquiry); menuCourseInquiry.setText("课程查询"); jMenuItem10.setText("按课程编号查询"); menuCourseInquiry.add(jMenuItem10); jMenuItem11.setText("按课程名查询"); menuCourseInquiry.add(jMenuItem11); jMenuItem12.setText("按授课老师查询"); menuCourseInquiry.add(jMenuItem12); menuInformationInquiry.add(menuCourseInquiry); menuScoreInquiry.setText("成绩查询"); jMenuItem13.setText("查询所有成绩 "); menuScoreInquiry.add(jMenuItem13); jMenuItem14.setText("查询单科成绩"); menuScoreInquiry.add(jMenuItem14); menuInformationInquiry.add(menuScoreInquiry); viewAllStuInfo.setText("所有学生信息"); viewAllStuInfo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { viewAllStuInfoActionPerformed(evt); } }); menuInformationInquiry.add(viewAllStuInfo); mainMenu.add(menuInformationInquiry); setJMenuBar(mainMenu); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void itemAddStuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemAddStuActionPerformed // TODO add your handling code here: AddStuInformation add = new AddStuInformation(); add.downInit(); add.validate(); add.setVisible(true); }//GEN-LAST:event_itemAddStuActionPerformed private void itemInquiryBySidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemInquiryBySidActionPerformed // TODO add your handling code here: }//GEN-LAST:event_itemInquiryBySidActionPerformed private void viewAllStuInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAllStuInfoActionPerformed // TODO add your handling code here: int rowcount = defaultTableModel.getRowCount()-1; while(rowcount >= 0) { defaultTableModel.removeRow(rowcount); defaultTableModel.setRowCount(rowcount); rowcount--; } int row = 0; int i = 0, j = 0; String[][] stu; StuBean getSno = new StuBean(); stu = getSno.getAllStuInfo(); for (i = 0; i < stu.length; i++) { defaultTableModel.addRow(stu[i]); //((DefaultTableModel) table.getModel()).addRow(stu[i]); } }//GEN-LAST:event_viewAllStuInfoActionPerformed private void menuLogOnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuLogOnActionPerformed // TODO add your handling code here: ManagerLogOn user = new ManagerLogOn(this,true); user.setVisible(true); if(user.isSucceedLogOn){ menuStuManagement.setEnabled(true); menuCourseManagement.setEnabled(true); menuScoreManagement.setEnabled(true); menuInformationInquiry.setEnabled(true); } }//GEN-LAST:event_menuLogOnActionPerformed private void itemAlterStuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemAlterStuActionPerformed // TODO add your handling code here: EditStuInformation editStu = new EditStuInformation(); editStu.downInit(); editStu.validate(); editStu.setVisible(true); }//GEN-LAST:event_itemAlterStuActionPerformed private void itemDeleteStuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemDeleteStuActionPerformed // TODO add your handling code here: DelStuInformation delStu = new DelStuInformation(); delStu.downInit(); delStu.validate(); delStu.setVisible(true); }//GEN-LAST:event_itemDeleteStuActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new stuMSJFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenuItem itemAddCourse; private javax.swing.JMenuItem itemAddScore; private javax.swing.JMenuItem itemAddStu; private javax.swing.JMenuItem itemAlterCourse; private javax.swing.JMenuItem itemAlterScore; private javax.swing.JMenuItem itemAlterStu; private javax.swing.JMenuItem itemDeleteCourse; private javax.swing.JMenuItem itemDeleteScore; private javax.swing.JMenuItem itemDeleteStu; private javax.swing.JMenuItem itemExit; private javax.swing.JMenuItem itemInquiryByScollege; private javax.swing.JMenuItem itemInquiryBySid; private javax.swing.JMenuItem itemInquiryBySname; private javax.swing.JMenuItem itemInquiryBySsex; private javax.swing.JMenuItem itemInquiryBySspecialSubject; private javax.swing.JMenuItem itemSC; private javax.swing.JMenuItem jMenuItem10; private javax.swing.JMenuItem jMenuItem11; private javax.swing.JMenuItem jMenuItem12; private javax.swing.JMenuItem jMenuItem13; private javax.swing.JMenuItem jMenuItem14; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator3; private javax.swing.JSeparator jSeparator4; private javax.swing.JSeparator jSeparator5; private javax.swing.JSeparator jSeparator6; private javax.swing.JMenuBar mainMenu; private javax.swing.JMenu menuCourseInquiry; private javax.swing.JMenu menuCourseManagement; private javax.swing.JMenu menuInformationInquiry; private javax.swing.JMenuItem menuLogOn; private javax.swing.JMenu menuScoreInquiry; private javax.swing.JMenu menuScoreManagement; private javax.swing.JMenu menuStuInquiry; private javax.swing.JMenu menuStuManagement; private javax.swing.JMenu menuSystemManagement; private javax.swing.JSeparator separator1; private javax.swing.JTable table; private javax.swing.JMenuItem viewAllStuInfo; // End of variables declaration//GEN-END:variables public void tableChanged(TableModelEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //获得改变行 int row = e.getFirstRow(); int column = e.getColumn(); if(column!=-1){ //System.out.println("修改了第"+row+"行,第"+column+"列的值"); StuBean editStu = new StuBean(); String Sno = String.valueOf(defaultTableModel.getValueAt(row, 0)); String Sname = String.valueOf(defaultTableModel.getValueAt(row, 1)); String Ssex = String.valueOf(defaultTableModel.getValueAt(row, 2)); String Sbirth = String.valueOf(defaultTableModel.getValueAt(row, 3)); String Shometown = String.valueOf(defaultTableModel.getValueAt(row, 4)); String Sethnic = String.valueOf(defaultTableModel.getValueAt(row, 5)); String Sdate = String.valueOf(defaultTableModel.getValueAt(row, 6)); String Smajor = String.valueOf(defaultTableModel.getValueAt(row, 7)); String Scollege = String.valueOf(defaultTableModel.getValueAt(row, 8)); editStu.stuModify(Sno, Sname, Ssex, Sbirth, Shometown, Sethnic, Sdate, Smajor, Scollege); } else{ System.out.println("修改了第"+row+"行所有列的值"); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -