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

📄 runframe.java

📁 运动会成绩管理系统
💻 JAVA
字号:
package system;
import javax.swing.*;

import java.sql.*;
import java.awt.Color;
import java.awt.TextField;
import java.awt.event.*;

import javax.swing.JFrame;

import user.add_user;
import user.quanxian;

public  class Runframe extends JFrame implements ActionListener
{
	 
	private static final long serialVersionUID = 1L;
	
	  JPanel cp;int i=0;
	
	  ImageIcon icon=new ImageIcon("picture/5.jpg");
	  JLabel tp=new JLabel(icon,JLabel.CENTER);
	  JLabel j1=new JLabel("姓名: ");
	  JLabel j2=new JLabel("密码: ");
      JLabel j3=new JLabel("南华大学运动会成绩管理系统");
	  
	  JButton b1=new JButton("登 录");
	  JButton b2=new JButton("注 册");
	  TextField t1=new TextField(20);
	  TextField t2=new TextField(16);
	
	  
	  public Runframe() 
	  {try{
		  Init();
	  }catch(Exception err){err.printStackTrace();}}
		  
		  
		  private void Init() throws Exception{
		   cp=(JPanel) this.getContentPane();
		   cp.setLayout(null);
		   this.setTitle("系统登录");
		   this.setResizable(false);
		   this.setSize(640,480);
		   
		   j1.setBounds(220,140,60,30);
		   j1.setFont(new java.awt.Font("Dialog",2,20));
		   j1.setForeground(new Color(250,0,0));
		   
		   j2.setBounds(220,190,60,30);
		   j2.setFont(new java.awt.Font("Dialog",2,20));
		   j2.setForeground(new Color(250,0,0));
		   
		   j3.setBounds(40,40,580,40);
		   j3.setFont(new java.awt.Font("Dialog",6,40));
		   j3.setForeground(new Color(250,0,0));
		   
		   
		  
		   t1.setBounds(280,140,120,30);
		   t1.setFont(new java.awt.Font("Dialog",0,15));
		   t1.setBackground(new Color(20,150,20));
		   t1.addActionListener(this);
		   
		   t2.setBounds(280,190,120,30);
		   t2.setFont(new java.awt.Font("Dialog",0,14));
		   t2.setBackground(new Color(20,150,20));
		   t2.addActionListener(this);
		   
		
		   b1.setBounds(200,290,90,30);
		   b1.setFont(new java.awt.Font("Dialog",0,15));
		   b1.addActionListener(this);
		   b2.setBounds(350,290,90,30);
		   b2.setFont(new java.awt.Font("Dialog",0,15));
		   b2.addActionListener(this);
		   
		   tp.setText("");
		   tp.setSize(640,480);
		   
		   cp.add(j1,null);
		   cp.add(j2,null);
		   cp.add(j3,null);
;
		   cp.add(t1,null);
		   cp.add(t2,null);
	
		   cp.add(b1,null);
		   cp.add(b2,null);
		  
		   cp.add(tp,null);
		   t2.setEchoChar('*');
		  
		
		  this.setLocationRelativeTo(null);
		  this.setVisible(true);
		  	  
	  }
	  public void actionPerformed(ActionEvent e)
	  {   
		  if(e.getSource()==b2){new add_user();}
	      else if(t1.getText().equals("")){JOptionPane.showMessageDialog(null,"请输入用户名!");t1.requestFocus();t2.setText("");}
	      else if(e.getSource()==t1){t2.requestFocus();}
	      else if(t2.getText().equals("")){JOptionPane.showMessageDialog(null,"请输入密码!");t2.requestFocus();}
	      else if(e.getSource()==t2||e.getSource()==b1)
		  try{
		          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			      Connection con=DriverManager.getConnection("jdbc:odbc:yundonghui","sa","123");
			      Statement ps=con.createStatement();
 
			      ResultSet rs=null;
			      rs=ps.executeQuery("select * from 用户管理 where 用户名='"+t1.getText().trim()+"'");

	           if(!rs.next())
			      {   
				   JOptionPane.showMessageDialog(null,"没有此用户请重新输入!");
			  	   t1.setText("");t2.setText("");t1.requestFocus();
			      }
	           else if(rs.getString(4).trim().equals("锁定")){JOptionPane.showMessageDialog(null, "此账号已被锁定,请求管理员解锁!");this.dispose();}
		      else
			      {rs=ps.executeQuery("select * from 用户管理 where 用户名='"+t1.getText().trim()+"'");
		    	  rs.next();   
			      String msg=rs.getString(1);
				     if(rs.getString(2).equals(t2.getText().trim()))
			             { new quanxian().user_type1(msg);new mainframe<Object, Object>();this.dispose();}
			         else
			             {
				           i++; 
				           if(i==3) 
				              {
				        	     JOptionPane.showMessageDialog(null,"密码三次输入错误!");
				        	    new quanxian().user_type2(msg); this.dispose();
				        	   }
			               else 
			                   {  JOptionPane.showMessageDialog(null,"密码输入错误!"); 
			                      t2.setText("");t2.requestFocus();
			                   }
			              }

			       }
		       }
		      catch (Exception err) { err.printStackTrace();JOptionPane.showMessageDialog(null,"数据库连接出错!"); }
		  
		  }

	  public static void main(String args[])
	  {new Runframe(); }
                          

}

⌨️ 快捷键说明

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