首页>代码>java swing开发进销存管理系统>/01/JXCManager/src/com/lzw/login/Login.java
package com.lzw.login;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

import model.TbUserlist;

import com.lzw.JXCFrame;
import com.lzw.dao.Dao;
public class Login extends JFrame {
	private JLabel userLabel;
	private JLabel passLabel;
	private JButton exit;
	private JButton login;
	private static TbUserlist user;
	public Login() {
		setTitle("登录企业进销存管理系统");
		final JPanel panel = new LoginPanel();
		panel.setLayout(null);
		getContentPane().add(panel);
		setBounds(300, 200, panel.getWidth(), panel.getHeight());
		userLabel = new JLabel();
		userLabel.setText("用户名:");
		userLabel.setBounds(100, 135, 200, 18);
		panel.add(userLabel);
		final JTextField userName = new JTextField();
		userName.setBounds(150, 135, 200, 18);
		panel.add(userName);
		passLabel = new JLabel();
		passLabel.setText("密  码:");
		passLabel.setBounds(100, 165, 200, 18);
		panel.add(passLabel);
		final JPasswordField userPassword = new JPasswordField();
		userPassword.addKeyListener(new KeyAdapter() {
			public void keyPressed(final KeyEvent e) {
				if (e.getKeyCode() == 10)
					login.doClick();
			}
		});
		userPassword.setBounds(150, 165, 200, 18);
		panel.add(userPassword);
		login = new JButton();
		login.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				user = Dao.getUser(userName.getText(), userPassword.getText());
				if (user.getUsername() == null || user.getName() == null) {
					userName.setText(null);
					userPassword.setText(null);
					return;
				}
				setVisible(false);
				new JXCFrame();
			}
		});
		login.setText("登录");
		login.setBounds(180, 195, 60, 18);
		panel.add(login);
		exit = new JButton();
		exit.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				System.exit(0);
			}
		});
		exit.setText("退出");
		exit.setBounds(260, 195, 60, 18);
		panel.add(exit);
		setVisible(true);
		setResizable(false);
		setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
	}
	public static TbUserlist getUser() {
		return user;
	}
	public static void setUser(TbUserlist user) {
		Login.user = user;
	}
}
最近下载更多
DoustrongWU  LV5 2月12日
machongqi168  LV1 2024年8月18日
qwe369  LV1 2023年5月18日
fghjksss  LV1 2023年5月8日
shuhong  LV6 2023年3月8日
JJ  LV1 2021年11月14日
dfsfvsr  LV2 2021年9月10日
gjynewer  LV15 2021年8月18日
zzfzzf  LV7 2021年6月16日
纯纯粹粹112332  LV6 2021年6月8日
最近浏览更多
dengge123  LV14 11月21日
wahukkk  LV1 6月22日
浪客剑心_星辰  LV2 2024年10月6日
machongqi168  LV1 2024年8月18日
893269222 2024年7月6日
暂无贡献等级
刘孟飞  LV22 2024年6月21日
ming_123_9715  LV23 2024年6月18日
疯子庭  LV8 2024年5月27日
genyuan2014  LV6 2024年5月7日
LTPR66  LV1 2023年11月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友