package d;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Calendar;
import java.util.Random;
import javax.swing.*;
public class NNN
{
public static void main(String[] args)
{
De s=new De();
s.set();
}
}
class De extends JFrame
{
private JFrame frame =new JFrame();
private JLabel title=new JLabel("欢迎登陆");
private JLabel name=new JLabel("账号");
private JLabel password=new JLabel("密码");
private JTextField number=new JTextField(13);
private JPasswordField id=new JPasswordField(13);
private JButton b=new JButton();
private JButton b1=new JButton("确定");
private JButton b2=new JButton("重置");
private JButton b3=new JButton("退出");
private JPanel p1=new JPanel();
private JPanel p2=new JPanel();
private JPanel p3=new JPanel();
private JPanel p4=new JPanel();
private JPanel p5=new JPanel();
private int a=0;
public void set()
{
//标题
Font m=new Font("华文行楷",1,50);
title.setFont(m);
title.setForeground(Color.RED);
//添加p1
p1.add(title);
//文本框
Font h=new Font("黑体",1,23);
Font s=new Font("",1,16);
name.setFont(h);
password.setFont(h);
number.setFont(s);
id.setFont(s);
//添加p2
p2.add(name);
p2.add(number);
//添加p3
p3.add(password);
p3.add(id);
//监听器
b1.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
sql(number.getText(),id.getPassword());
if(a==1)
{
JOptionPane.showMessageDialog(null,"验证正确,即将进入程序,请稍后......");
show();
frame.dispose();
}
if(a==0)
{
JOptionPane.showMessageDialog(null,"验证错误,请重新输入......");
number.setText("");
id.setText("");
}
}
}
);
b2.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
number.setText("");
id.setText("");
}
}
);
b3.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,"即将退出程序,请稍后......");
System.exit(0);
}
}
);
p4.add(b1);
p4.add(b2);
p4.add(b3);
//设置框架
frame.setLayout(new GridLayout(0,1));
frame.add(p1);
frame.add(p2);
frame.add(p3);
frame.add(p4);
frame.setTitle("登陆");
frame.setVisible(true);
frame.setBounds(800, 300,500,400);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void sql(String s1,char c[])
{
Connection co=null;
PreparedStatement pps=null;
ResultSet rr=null;
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e)
{
// TODO 自动生成的 catch 块
e.printStackTrace();
}
String m1="jdbc:mysql://localhost:3306/login?useUnicode=true&characterEncoding=utf8";
String m2="root";
String m3="root";
try
{
co=DriverManager.getConnection(m1, m2, m3);
String sql="select id,password from Plane";
pps=co.prepareStatement(sql);
rr=pps.executeQuery();
while(rr.next())
{
String ss=rr.getString(1);
String sss=rr.getString(2);
c=id.getPassword();
String s2=new String(c);
if(ss.equals(s1) && sss.equals(s2))
{
a=1;
}
}
}
catch (SQLException e)
{
// TODO 自动生成的 catch 块
e.printStackTrace();
}
finally
{
try
{
rr.close();
pps.close();
co.close();
}
catch (SQLException e)
{
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
}
public void show()
{
JFrame frame=new JFrame();
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JLabel title=new JLabel("欢迎使用");
title.setFont(new Font("华为行楷",1,40));
title.setForeground(Color.red);
JButton b1=new JButton("返回");
b1.setFont(new Font("隶书",1,24));
p1.add(title);
p2.add(b1);
b1.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,"即将返回,请稍后......");
De h=new De();
h.set();
frame.dispose();
}
}
);
frame.add(p1,BorderLayout.NORTH);
frame.add(p2,BorderLayout.SOUTH);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setBounds(600,300,400,200);
}
}
denglu.zip_源码
版权申诉
59 浏览量
2022-09-24
09:36:58
上传
评论
收藏 683KB ZIP 举报
JonSco
- 粉丝: 66
- 资源: 1万+
最新资源
- C语言基础-C语言编程基础之Leetcode编程题解之第39题组合总和.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第38题外观数列.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第37题解数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第36题有效的数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第35题搜索插入位置.zip
- index.wxml
- C语言基础-C语言编程基础之Leetcode编程题解之第33题搜索旋转排序数组.zip
- 基于Python实现的手写数字识别系统源码.zip
- 从网页提取禁止转载的文字
- C语言基础-C语言编程基础之Leetcode编程题解之第32题最长有效括号.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈