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

📄 login.java

📁 管理系统有一个包
💻 JAVA
字号:
package com.ysl.view;

import java.awt.Container;
import java.awt.GridLayout;
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.JPanel;
import javax.swing.JTextField;

import com.ysl.dao.UserDao;
import com.ysl.model.User;

public class Login extends JFrame implements ActionListener{
   JTextField t1,t2;
   JButton b1,b2;
   public Login()
   {
	   t1=new JTextField(10);
	   t2=new JTextField(10);
	   b1=new JButton("登录");
	   b2=new JButton("取消");
	   JPanel p1=new JPanel();
	   JPanel p2=new JPanel();
	   JPanel p3=new JPanel();
	   p1.add(new JLabel("用户"));
	   p1.add(t1);
	   p2.add(new JLabel("密码"));
	   p2.add(t2);
	   p3.add(b1);
	   p3.add(b2);
	   Container cc=this.getContentPane();
	   cc.setLayout(new GridLayout(3,1));
	   cc.add(p1);
	   cc.add(p2);
	   cc.add(p3);
	   b1.addActionListener(this);
	   b2.addActionListener(this);
	   
	   setTitle("登录窗口");
	   setSize(200,150);
	   this.setLocation(400,200);
	   setVisible(true);
   }
public void actionPerformed(ActionEvent e) {
	if(e.getSource()==b1)
	{
		UserDao ud=new UserDao();
		User user=ud.checkUser(t1.getText(), t2.getText());
		if(user!=null)
		{
			new UserManage();
			dispose();
		}
		else
		{
			JOptionPane.showMessageDialog(null, "用户名或密码错误");
		}
	}
	else
	{
		dispose();
		System.exit(0);
	}
}
}

⌨️ 快捷键说明

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