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

📄 searchmen.java

📁 学生管理系统.对学生信息管理的一个应用软件!
💻 JAVA
字号:
import java .awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.Box;
class Mypanel1 extends Panel 
{  Box baseBox,boxV1,boxV2;
   Label nameLabel,noLabel,classLabel;
   TextField nameText,noText,classText;
   Button sureButton;
   Mypanel1()
   {    nameLabel=new Label("姓名",Label.LEFT);
	    noLabel=new Label("学号",Label.LEFT);
	    classLabel=new Label("班级",Label.LEFT);
	    nameText=new TextField(10);
	    noText=new TextField(10);
	    classText=new TextField(10);
	    sureButton=new Button("确定");
	    
	    boxV1=Box.createVerticalBox();
		boxV1.add(nameLabel);
	    boxV1.add(Box.createVerticalStrut(18));
	    boxV1.add(noLabel);
	    boxV1.add(Box.createVerticalStrut(18));
	    boxV1.add(classLabel);
	    
	    boxV2=Box.createVerticalBox();
		boxV2.add(nameText);
	    boxV2.add(Box.createVerticalStrut(18));
	    boxV2.add(noText);
	    boxV2.add(Box.createVerticalStrut(18));
	    boxV2.add(classText);
		  
	    
	    baseBox=Box.createHorizontalBox();
	    baseBox.add(boxV1);
	    baseBox.add(boxV2);
		add(baseBox);
		add(sureButton);
	    
   }
}

class searchWindow1 extends JFrame implements ActionListener
{  
   Mypanel1 panel1;
   TextArea  text;
   searchWindow1(String s)
   {   super(s);
       setLayout(new FlowLayout());
	   panel1=new Mypanel1();
	   add(panel1);
	   text=new TextArea(10,20);
	   text.setEditable(false);
	   add(text);
	   panel1.sureButton.addActionListener(this);
	   
	   this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	   
	  
       setBounds(120,150,250,350);
       setVisible(true);
       validate();
    }
   public void actionPerformed(ActionEvent e)
   {   
	   Connection con;
       Statement sql;
       ResultSet rs;
       String s1=panel1.nameText.getText();
       String s2=panel1.noText.getText();
       String s3=panel1.classText.getText();
       try
       {
    	   Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver");
       }
       catch(ClassNotFoundException k){}
       try
       {
    	   con=DriverManager.getConnection("jdbc:odbc:sun","","");
    	   sql=con.createStatement();
    		   System.out.print("wewe");
    		   rs=sql.executeQuery("SELECT * FROM 学生个人信息表 WHERE name LIKE '"+s1+"'");
    		   while(rs.next())
    		   {  
    			   String no =rs.getString(1);
    			   String name =rs.getString(2);
    			   String sex =rs.getString(3);
    			   String deparment =rs.getString(4);
    			   String banji =rs.getString(5);
    			   String birthday =rs.getString(6);
    			   String nativeplace =rs.getString(7);
    			   text.append("学号:"+no);
    			   text.append("\n姓名:"+name);
              	   text.append("\n性别:"+sex);
              	   text.append("\n系别:"+deparment);
              	   text.append("\n班级: "+banji);
              	   text.append("\n生日: "+birthday);
              	   text.append("\n籍贯: "+nativeplace);
            	  }
    		   con.close();
    	   }
       catch(SQLException k)
       {
    	   System.out.println(k);
       }
   }
   }

⌨️ 快捷键说明

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