//登陆界面
package com.view;
import java.awt.Color;
/**
* 登陆
* @author Administrator
*
*/
/**
* 成员变量
*/
private static final long serialVersionUID = 1L;
//北部
//中部
private JLabel nameLab,pswLab
;
//监听处理
private AdminDao admin;
/**
* 入口
*/
public static void main
(String[] args
) {
try {
// String lookAndFeel =
// UIManager.getCrossPlatformLookAndFeelClassName();
UIManager.
setLookAndFeel(new BernsteinLookAndFeel
());
//UIManager.setLookAndFeel(new McWinLookAndFeel());
//UIManager.setLookAndFeel(new MetalLookAndFeel());
}
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.setBounds(0, 0, 450, 120);
getContentPane().add(topImg);
panel1.setBounds(0, 120, 450, 220);
panel1.setLayout(null);
nameLab.setFont(MySetFont.f6);
nameLab.setBounds(46, 10, 69, 35);
panel1.add(nameLab);
nameTex.setBounds(135, 10, 155, 35);
panel1.add(nameTex);
nameTex.addActionListener(this);//监听2
nameTex.setColumns(10);
pswLab.setFont(MySetFont.f6);
pswLab.setBounds(46, 60, 69, 35);
panel1.add(pswLab);
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.setBounds(300, 10, 108, 35);
forgetLab.addMouseListener(this);//监听1
panel1.add(forgetLab);
insertLab
= new JLabel("注册账号");
insertLab.setBounds(300, 60, 108, 35);
insertLab.setFont(MySetFont.f3);
insertLab.
setForeground(Color.
blue);
insertLab.addMouseListener(this);//监听1
panel1.add(insertLab);
alertLab.
setForeground(Color.
RED);
alertLab.setFont(MySetFont.f3);
alertLab.setBounds(135, 95, 273, 35);
panel1.add(alertLab);
intoBut
= new JButton("<html>登 陆</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
//点击
if(de.getSource()==forgetLab){
new InTo_Forget();
this.dispose();
}else if(de.getSource()==insertLab){
//注册
this.dispose();
}
}
@Override
// 进入
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
// 移除
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
// TODO Auto-generated method stub
}
@Override
// TODO Auto-generated method stub
}
//////////////////////////////////////////////基本监听2
@Override
String name
=nameTex.
getText();
if(de.getSource()==nameTex){
pswTex.requestFocus();//获得焦点
}else if(de.getSource()==pswTex){
doPD(name,psw);
}else if(de.getSource()==intoBut){
doPD(name,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");
this.dispose();
}else{
//no
alertLab.setText("登陆失败");
}
}else{
//填写
alertLab.setText("填写");
}
}
}