用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

登陆界面设计

2014-05-10 作者: 云代码会员举报

[java]代码库

//登陆界面
package com.view;

import java.awt.Color;
/**
 * 登陆
 * @author Administrator
 *
 */
public class InTo extends JFrame implements ActionListener,MouseListener{

	/**
	 * 成员变量
	 */
	private static final long serialVersionUID = 1L;
	//北部
	private JLabel topImg ;
	//中部
	private JPanel panel1; 
	private JLabel nameLab,pswLab;
	private JTextField nameTex;
	private JPasswordField pswTex;
	JLabel forgetLab;
	private JLabel insertLab;
	private JButton intoBut; 
	//监听处理
	private AdminDao admin;
	private JLabel alertLab;
	

	/**
	 * 入口
	 */
	public static void main(String[] args) {
		
		try {
			// String lookAndFeel =
			// UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(new BernsteinLookAndFeel());
			//UIManager.setLookAndFeel(new McWinLookAndFeel());
			//UIManager.setLookAndFeel(new MetalLookAndFeel());

		} catch (Exception e) {
		}
		new InTo();

	}

	/**
	 * 初始化
	 */
	public InTo() {
		admin=new AdminDao();
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle("鑫鑫图书管理登陆");
		this.setUndecorated(true);//去掉窗口的装饰
		this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);////设置为简单对话窗口
		setIconImage(Toolkit.getDefaultToolkit().getImage("QQ图标/a.png"));
		setSize(450, 340);
		this.setLocationRelativeTo(null);
		getContentPane().setLayout(null);
		
		JLabel alert = new JLabel("<html><font face='行楷' size=5 color=red><b>鑫 鑫 图 书 管 理 系 统</b></font><br/><font color=white>DA BING TU SHU GUAN LI XING TONG</html>");
		alert.setBounds(221, -11, 300, 83);
		getContentPane().add(alert);
		
		topImg= new JLabel(new ImageIcon("image/图书馆登陆.jpg"));
		topImg.setBounds(0, 0, 450, 120);
		getContentPane().add(topImg);
		
		panel1 = new JPanel();
		panel1.setBounds(0, 120, 450, 220);
		panel1.setLayout(null);
		
		nameLab = new JLabel("用户名:");
		nameLab.setFont(MySetFont.f6);
		nameLab.setBounds(46, 10, 69, 35);
		panel1.add(nameLab);
		
		nameTex = new JTextField();
		nameTex.setBounds(135, 10, 155, 35);
		panel1.add(nameTex);
		nameTex.addActionListener(this);//监听2
		nameTex.setColumns(10);
		
		pswLab = new JLabel("密码:");
		pswLab.setFont(MySetFont.f6);
		pswLab.setBounds(46, 60, 69, 35);
		panel1.add(pswLab);
		
		pswTex = new JPasswordField();
		pswTex.setBounds(135, 60, 155, 35);
		pswTex.addActionListener(this);//监听2
		panel1.add(pswTex);
		
		forgetLab = new JLabel("忘记密码");
		forgetLab.setForeground(Color.red);
		forgetLab.setFont(MySetFont.f3);
		forgetLab.setHorizontalAlignment(SwingConstants.CENTER);
		forgetLab.setBounds(300, 10, 108, 35);
		forgetLab.addMouseListener(this);//监听1
		panel1.add(forgetLab);
		
		insertLab = new JLabel("注册账号");
		insertLab.setHorizontalAlignment(SwingConstants.CENTER);
		insertLab.setBounds(300, 60, 108, 35);
		insertLab.setFont(MySetFont.f3);
		insertLab.setForeground(Color.blue);
		insertLab.addMouseListener(this);//监听1
		panel1.add(insertLab);
		
		alertLab = new JLabel();
		alertLab.setHorizontalAlignment(SwingConstants.LEFT);
		alertLab.setForeground(Color.RED);
		alertLab.setFont(MySetFont.f3);
		alertLab.setBounds(135, 95, 273, 35);
		panel1.add(alertLab);
		
		intoBut = new JButton("<html>登&nbsp;&nbsp;陆</html>");
		intoBut.setFont(MySetFont.f3);
		intoBut.setBounds(135, 140, 155, 37);
		intoBut.addMouseListener(this);//监听1
		intoBut.addActionListener(this);
		panel1.add(intoBut);
		
		getContentPane().add(panel1);
		
	
		
		this.setVisible(true);
	
	}
	/////////////////////////////////////////////////鼠标监听1
	@Override
	public void mouseClicked(MouseEvent de) {
		//点击
		if(de.getSource()==forgetLab){
			new InTo_Forget();
			this.dispose();
		}else if(de.getSource()==insertLab){
			//注册
			this.dispose();
		}
		
	}

	@Override
	public void mouseEntered(MouseEvent de) {
		// 进入
		if(de.getSource()==forgetLab){
			forgetLab.setFont(MySetFont.f1);
		}else if(de.getSource()==insertLab){
			insertLab.setFont(MySetFont.f1);
		}else if(de.getSource()==intoBut){
			intoBut.setForeground(Color.red);
		}
		
	}

	@Override
	public void mouseExited(MouseEvent de) {
		// 移除
		if(de.getSource()==forgetLab){
			forgetLab.setFont(MySetFont.f3);
		}else if(de.getSource()==insertLab){
			insertLab.setFont(MySetFont.f3);
		}else if(de.getSource()==intoBut){
			intoBut.setForeground(Color.black);
		}
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	//////////////////////////////////////////////基本监听2
	@Override
	public void actionPerformed(ActionEvent de) {
		String name=nameTex.getText();
		String psw=new String(pswTex.getPassword());
		
		if(de.getSource()==nameTex){
			
			pswTex.requestFocus();//获得焦点
			
		}else if(de.getSource()==pswTex){
			
			doPD(name,psw);
			
		}else if(de.getSource()==intoBut){
			doPD(name,psw);
		}
	}
	
	/**
	 * 登陆的判断
	 */
	public void doPD(String name,String psw){
		AdminPoJo pojo=new AdminPoJo();
		if(StringUtil.isNotNull(name)&&StringUtil.isNotNull(psw)){
			pojo.setName(name);
			pojo.setPassword(psw);
			AdminPoJo pojo1=admin.doInTo(pojo);
			if(pojo1!=null){
				//ok登陆
				alertLab.setText("ok");
				new Menu();
				this.dispose();
			}else{
				//no
				alertLab.setText("登陆失败");
			}
		}else{
			//填写
			alertLab.setText("填写");
		}
	}
}


网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...