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

📄 techertable.java

📁 这个是我二年级写的一个教务管理系统 大家可以下来
💻 JAVA
字号:
package caoyu;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
class TecherTable extends JFrame implements ActionListener {
   public JRadioButton name = null;
   public JRadioButton tno = null;
   public JTextField jt = null;
   public JButton btn = null;
   public JButton teacher_serch =new JButton("教师授课信息查询");
   public JTable table = null;
   public TecherTable() 
   {
      this.initFrame();
      this.setTitle("教师信息系统");
      setSize(650,300);
      setVisible(true);
  }
  public void initFrame()
  {
     Container container = this.getContentPane();
      String[][] p = new String[10][10];
      String[] n = {"tno","tname","tsex","birthday","duty","post","politic","office","telephone","address"};
      table = new JTable(p,n);
      JLayeredPane jlp=new JLayeredPane();
      jlp.setLayout(new GridLayout(1,5));//生成布局
      
      JScrollPane s = new JScrollPane(table);
      container.add(s, BorderLayout.CENTER);
    
      name = new JRadioButton( "姓名" );
      tno = new JRadioButton( "教师号");

      btn = new JButton( "查询" );
      jlp.add( name );
      jlp.add( tno);
      ButtonGroup buttongroup=new ButtonGroup();
      buttongroup.add(name);
      buttongroup.add(tno);
      jlp.add( teacher_serch );
      jlp.add( btn );
      jt = new JTextField( 10 );
      jlp.add( jt );
      container.add(jlp, BorderLayout.NORTH);
      btn.addActionListener(this);
      teacher_serch.addActionListener(this);
      	 
          }

         public void actionPerformed(ActionEvent e)
      	    {    if(e.getSource()==btn&&tno.isSelected())//按教师号查询教师信息(视图)
      	        
      	       { try {
      	 	      DBOperatorTeacher op = new DBOperatorTeacher();
      	 	      
      	 	     // ResultSet rs = op.queryTeacher(jt.getText().trim());
      	 	      ResultSet rs=op.queryTeacher(jt.getText().trim());
      	 	     
      	 	      
      	          for(int i=0;rs.next();i++)
					{
						table.setValueAt(rs.getString(1),i,0);
						table.setValueAt(rs.getString(2),i,1);
						table.setValueAt(rs.getString(3),i,2);
						table.setValueAt(rs.getString(4),i,3);
						table.setValueAt(rs.getString(5),i,4);
						table.setValueAt(rs.getString(6),i,5);
						table.setValueAt(rs.getString(7),i,6);
						table.setValueAt(rs.getString(8),i,7);
						table.setValueAt(rs.getString(9),i,8);
						table.setValueAt(rs.getString(10),i,9);
					//	table.setValueAt(rs.getString(6),i,5);
						
					}
			   rs.close();
               op.conn.close();
               }
               catch(Exception ex) {
                  //System.out.println(ex.getMessage());
                  ex.printStackTrace();	
               }}
               
               else if(e.getSource()==btn&&name.isSelected())//按教师姓名查询教师信息(视图)
      	        
      	       { try {
      	 	      DBOperatorTeacher op = new DBOperatorTeacher();
      	 	      
      	 	     // ResultSet rs = op.queryTeacher(jt.getText().trim());
      	 	      ResultSet rs=op.queryTeacher3(jt.getText().trim());
      	 	     
      	 	      
      	          for(int i=0;rs.next();i++)
					{
						table.setValueAt(rs.getString(1),i,0);
						table.setValueAt(rs.getString(2),i,1);
						table.setValueAt(rs.getString(3),i,2);
						table.setValueAt(rs.getString(4),i,3);
						table.setValueAt(rs.getString(5),i,4);
						table.setValueAt(rs.getString(6),i,5);
						table.setValueAt(rs.getString(7),i,6);
						table.setValueAt(rs.getString(8),i,7);
						table.setValueAt(rs.getString(9),i,8);
						table.setValueAt(rs.getString(10),i,9);
					//	table.setValueAt(rs.getString(6),i,5);
						
					}
			   rs.close();
               op.conn.close();
               }
               catch(Exception ex) {
                  //System.out.println(ex.getMessage());
                  ex.printStackTrace();	
               }}
               
               else if(e.getSource()==teacher_serch)        //查询教师授课情况(视图实现)
                {
                	search_teaching_information a= new search_teaching_information();
                	}
               
               else JOptionPane.showMessageDialog(this,"请输入相关信息");
            }
  
  
   public static void main(String args[])
  {
    TecherTable a=new  TecherTable();
  }	
  
  }
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -