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

📄 login.java

📁 JAVA图书管理软件源码,是我师兄亲自参与编的毕业设计
💻 JAVA
字号:
package com.ivan.login;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;

import com.ivan.menu.Menu;
import com.ivan.userManage.ActiveUser;
import javax.swing.ImageIcon;

public class Login extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JLabel jLabel = null;
	private JTextField jTextField = null;
	private JLabel jLabel1 = null;
	private JPasswordField jPasswordField = null;
	private JButton jButton = null;
	private JButton jButton1 = null;
	private JLabel jLabel2 = null;
	/**
	 * This method initializes jTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField() 
	{
		if (jTextField == null) 
		{
			jTextField = new JTextField();
			jTextField.setBounds(new Rectangle(164, 32, 93, 27));
		}
		return jTextField;
	}

	/**
	 * This method initializes jPasswordField	
	 * 	
	 * @return javax.swing.JPasswordField	
	 */
	private JPasswordField getJPasswordField()
	{
		if (jPasswordField == null)
		{
			jPasswordField = new JPasswordField();
			jPasswordField.setBounds(new Rectangle(165, 75, 92, 26));
		}
		return jPasswordField;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() 
	{
		if (jButton == null) 
		{
			jButton = new JButton();
			jButton.setBounds(new Rectangle(65, 146, 85, 23));
			jButton.setFont(new Font("Dialog", Font.BOLD, 14));
			jButton.setText("登  录");
			jButton.addActionListener(new java.awt.event.ActionListener()
			{
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					char c[]=jPasswordField.getPassword();
					String pwd="";
					for(int i=0;i<c.length;i++)  pwd+=c[i];
					
					ActiveUser.setActiveUser(jTextField.getText());
					
					if(CheckLogin.Check(jTextField.getText(),pwd)==true)
					{
						JOptionPane.showMessageDialog(null, "成功登录!");
						Menu.goToMenu();
						dele();
					}
					else
						JOptionPane.showMessageDialog(null, "登录失败,请检查用户名和密码!");
				}
			});
		}
		return jButton;
	}

	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private void dele()
	{
		this.dispose();
	}
	private JButton getJButton1()
	{
		if (jButton1 == null)
		{
			jButton1 = new JButton();
			jButton1.setBounds(new Rectangle(190, 144, 86, 24));
			jButton1.setFont(new Font("Dialog", Font.BOLD, 14));
			jButton1.setText(" 取   消");
			jButton1.addActionListener(new java.awt.event.ActionListener() 
			{
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					//System.out.println("actionPerformed()"); 
					
					System.exit(0);
					
					
				}
			});
		}
		return jButton1;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		SwingUtilities.invokeLater(new Runnable()
		{
			public void run() {
				Login thisClass = new Login();
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				thisClass.setVisible(true);
			}
		});
	}

	
	public static void loginFace()
	{
		// TODO Auto-generated method stub
		SwingUtilities.invokeLater(new Runnable()
		{
			public void run() {
				Login thisClass = new Login();
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				thisClass.setVisible(true);
			}
		});
	}
	/**
	 * This is the default constructor
	 */
	public Login() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(381, 236);
		this.setResizable(false);
		this.setLocation(400, 300);
		this.setContentPane(getJContentPane());
		this.setContentPane(getJContentPane());
		this.setTitle("图书管理系统---管理员登陆");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(297, 30, 41, 42));
			jLabel2.setIcon(new ImageIcon(getClass().getResource("/image/4.gif")));
			jLabel2.setText("JLabel");
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(55, 76, 68, 27));
			jLabel1.setFont(new Font("Dialog", Font.BOLD, 14));
			jLabel1.setText("   密  码");
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(55, 32, 70, 30));
			jLabel.setFont(new Font("Dialog", Font.BOLD, 14));
			jLabel.setText("  管理员");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(jLabel, null);
			jContentPane.add(getJTextField(), null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(getJPasswordField(), null);
			jContentPane.add(getJButton1(), null);
			jContentPane.add(getJButton(), null);
			jContentPane.add(jLabel2, null);
		}
		return jContentPane;
	}

	
	
}  //  @jve:decl-index=0:visual-constraint="217,70"

⌨️ 快捷键说明

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