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

📄 login.java

📁 学生选课管理系统
💻 JAVA
字号:
package main;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import db.StudentinformationBiz;


public class Login extends JFrame implements ActionListener{
	JLabel unameLabel;
	JLabel pwLabel;
	JButton enter;
	JButton cancle;
	JTextField jtname;
	JPasswordField jtpassword;
	public Login(){
		init1();
		init2();
		init3();
	}
	public void init1(){
		unameLabel=new JLabel("用户名:");
		pwLabel=new JLabel("密 码:");
		enter=new JButton("确定");
		cancle=new JButton("取消");
		jtname=new JTextField();
		jtpassword=new JPasswordField();
	}
	public void init2(){
		this.setLayout(null);
		this.setSize(280,344);
		this.setLocationRelativeTo(this);
		this.unameLabel.setBounds(30, 40, 75, 30);
		this.pwLabel.setBounds(30, 85, 55, 25);
		this.jtname.setBounds(95, 35, 110, 35);
		this.jtpassword.setBounds(95,85,110,35);
		this.enter.setBounds(35, 200, 65, 35);
		this.cancle.setBounds(150,200,70,35);
		this.add(this.unameLabel);
		this.add(this.pwLabel);
		this.add(jtname);
		this.add(jtpassword);
		this.add(enter);
		this.add(cancle);
	}
	public void init3(){
		this.setTitle("学生信息管理系统");
		this.enter.addActionListener(this);
		this.cancle.addActionListener(this);
		this.setResizable(false);
		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		String msg=e.getActionCommand();
		if(msg.equals("取消")){
			System.exit(0);
		}else{
			Enter();
		}
		
	}
	private void Enter() {
		String userName=jtname.getText();
		String password=new String (jtpassword.getPassword());
		StudentinformationBiz db=new StudentinformationBiz();

		boolean success=db.find(userName,password);
		if(success){
			new Main();
			this.dispose();
		}else{
			JOptionPane.showConfirmDialog(this,"对不起,密码或用户名错误!","错误",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE,null);	
		}
	}
	public static void main(String[]args){
		new Login();
	}
}

⌨️ 快捷键说明

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