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

📄 loginform.java

📁 图书管理系统 运行环境 windows 2003 windows xp
💻 JAVA
字号:
package com.book.ui;

import java.awt.GridLayout;

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 com.book.domain.User;
import com.book.service.LogonService;
import com.book.service.LogonServiceImp;

public class LoginForm extends JFrame {

	private JPanel jContentPane = null;

	private JPanel jPanel1 = null;

	private JPanel jPanel2 = null;

	private JPanel jPanel3 = null;

	private JLabel labelUserName = null;

	private JTextField txtUserName = null;

	private JPasswordField txtPassword = null;

	private JLabel labelPwd = null;

	private JButton butOk = null;

	private JButton butCancel = null;

	/**
	 * This is the default constructor
	 */
	public LoginForm() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(287, 134);
		this.setLocation(260,260);
		this.setContentPane(getJContentPane());
		this.setTitle("用户登录");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			GridLayout gridLayout = new GridLayout(3, 1);
			jContentPane = new JPanel();
			jContentPane.setLayout(gridLayout);
			jContentPane.add(getJPanel3(), null);
			jContentPane.add(getJPanel2(), null);
			jContentPane.add(getJPanel1(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanel1
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			jPanel1 = new JPanel();
			jPanel1.add(getButOk(), null);
			jPanel1.add(getButCancel(), null);
		}
		return jPanel1;
	}

	/**
	 * This method initializes jPanel2
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel2() {
		if (jPanel2 == null) {
			labelPwd = new JLabel();
			labelPwd.setText("口    令:    ");
			jPanel2 = new JPanel();
			jPanel2.add(labelPwd, null);
			jPanel2.add(getTxtPassword(), null);
		}
		return jPanel2;
	}

	/**
	 * This method initializes jPanel3
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel3() {
		if (jPanel3 == null) {
			labelUserName = new JLabel();
			labelUserName.setText("用户名 :    ");
			jPanel3 = new JPanel();
			jPanel3.add(labelUserName, null);
			jPanel3.add(getTxtUserName(), null);
		}
		return jPanel3;
	}

	/**
	 * This method initializes txtUserName
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtUserName() {
		if (txtUserName == null) {
			txtUserName = new JTextField(10);
		}
		return txtUserName;
	}

	/**
	 * This method initializes txtPassword
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getTxtPassword() {
		if (txtPassword == null) {
			txtPassword = new JPasswordField(10);
		}
		return txtPassword;
	}

	/**
	 * This method initializes butOk
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getButOk() {
		if (butOk == null) {
			butOk = new JButton();
			butOk.setText("确定");
			butOk.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {

					LogonService sv = new LogonServiceImp();
					User user = sv.getUserInfo(txtUserName.getText(),
							txtPassword.getText());
					if (user != null) {
						MainForm mainForm = new MainForm();
						mainForm.setVisible(true);
						setVisible(false);
					} else {
						setTitle("用户登录-登录失败");
					}

				}
			});
		}
		return butOk;
	}

	/**
	 * This method initializes butCancel
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getButCancel() {
		if (butCancel == null) {
			butCancel = new JButton();
			butCancel.setText("取消");
			butCancel.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					txtUserName.setText("");
					txtPassword.setText("");
				}
			});
		}
		return butCancel;
	}

} 

⌨️ 快捷键说明

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