package limengjie; |
import java.awt.Color; |
import java.awt.Font; |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
import java.awt.event.MouseEvent; |
import java.awt.event.MouseListener; |
import java.sql.Connection; |
import java.sql.PreparedStatement; |
import java.sql.ResultSet; |
import java.sql.SQLException; |
import java.sql.Statement; |
import javax.swing.ImageIcon; |
import javax.swing.JButton; |
import javax.swing.JFrame ; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JPasswordField; |
import javax.swing.JTextField; |
public class JqqF extends JFrame implements MouseListener { |
private static final long serialVersionUID = 1L; |
public static void main(String args[]) { |
JqqF f = new JqqF(); |
|
} |
|
public static JTextField name = new JTextField( 20 ); |
JLabel nameLab = new JLabel( "输入qq号:" ); |
public static JPasswordField nam = new JPasswordField( 20 ); |
JLabel nameLa = new JLabel( "输入qq密码:" ); |
String path5 = "pic//x.png" ; |
// 背景图片 |
ImageIcon background5 = new ImageIcon(path5); |
cell but = new cell(background5); |
Font fnt = new Font( "Serief" , Font.BOLD, 15 ); |
String path4 = "pic//l.png" ; |
|
ImageIcon background4 = new ImageIcon(path4); |
|
//cell bt = new cell(background4); |
cell bt = new cell( "注册账号" ); |
Font fnt1 = new Font( "Serief" , Font.BOLD, 11 ); |
|
String path3 = "pic//b.png" ; |
|
ImageIcon background3 = new ImageIcon(path3); |
|
// cell bt2 = new cell(background3); |
cell bt2 = new cell( "找回密码" ); |
Font fnt2 = new Font( "Serief" , Font.BOLD, 11 ); |
String path2= "pic//qq3.png" ; |
|
ImageIcon background2= new ImageIcon(path2); |
JLabel label2 = new JLabel(background2); |
|
|
public JqqF() { |
super ( "qq聊天系统" ); |
this .setSize( 500 , 334 ); |
this .setLocation( 300 , 200 ); |
|
this .setVisible( true ); |
String path = "pic//qq.png" ; |
// 背景图片 |
ImageIcon background = new ImageIcon(path); |
// 把背景图片显示在一个标签里面 |
JLabel label = new JLabel(background); |
label.setLayout( null ); |
// 把标签的大小位置设置为图片刚好填充整个面板 |
label.setBounds( 0 , 0 , this .getWidth(), this .getHeight()); |
// 把内容窗格转化为JPanel,否则不能用方法setOpaque()来使内容窗格透明 |
JPanel imagePanel = (JPanel) this .getContentPane(); |
imagePanel.setOpaque( false ); |
// 把背景图片添加到分层窗格的最底层作为背景 |
|
nameLab.setFont(fnt); |
nameLab.setForeground(Color.blue); |
nameLa.setFont(fnt); |
nameLa.setForeground(Color.blue); |
bt.setFont(fnt1); |
bt.setForeground(Color.black); |
bt2.setFont(fnt2); |
bt2.setForeground(Color.black); |
nameLab.setBounds( 160 , 120 , 100 , 30 ); |
bt.setBounds( 360 , 120 , 88 , 25 ); |
bt.addActionListener( new ActionListener(){ |
@Override |
public void actionPerformed(ActionEvent e) { |
register x = new register(); |
|
|
} |
|
}); |
name.setBounds( 250 , 120 , 108 , 25 ); |
nameLa.setBounds( 160 , 160 , 100 , 30 ); |
nam.setBounds( 250 , 160 , 108 , 25 ); |
bt2.setBounds( 360 , 160 , 88 , 25 ); |
bt2.addActionListener( new ActionListener(){ |
@Override |
public void actionPerformed(ActionEvent e) { |
new findpassword(); |
|
|
} |
|
}); |
//// nam.setColumns(20) ; |
label2.setBounds( 65 , 120 , 88 , 83 ); |
but.setBounds( 185 , 210 , 147 , 30 ); |
but.addMouseListener( this ); |
label.add(nameLab); |
label.add(bt); |
label.add(bt2); |
label.add(nam); |
label.add(nameLa); |
label.add(label2); |
label.add(name); |
label.add(but); |
this .getLayeredPane().add(label, new Integer(Integer.MIN_VALUE)); |
this .setResizable( false ); |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
// 让组件可见 |
} |
public void mouseClicked(MouseEvent e) { |
char [] a = nam.getPassword(); |
String s = new String(a); |
|
//System.out.print(s); |
String b = "1" ; |
Statement st = null ; |
ResultSet rs = null ; |
boolean t = false ; |
boolean x = false ; |
Connection con = null ; |
|
String sql = "SELECT name,mibao,password FROM qq" ; |
try { |
con= new JavaMysql().connnecton(); |
st = con.createStatement(); |
rs = st.executeQuery(sql); |
|
} catch (ClassNotFoundException e2) { |
// TODO Auto-generated catch block |
e2.printStackTrace(); |
} catch (SQLException e2) { |
// TODO Auto-generated catch block |
e2.printStackTrace(); |
} |
try { |
while (rs.next()){ |
String qq = rs.getString( "name" ); |
String password1 = rs.getString( "password" ); |
if (qq.equals(name.getText())){ |
t = true ; |
|
if (password1.equals(nam.getText())){ |
x = true ; |
} |
} |
|
|
} |
con.close(); |
st.close(); |
rs.close(); |
} catch (SQLException e1) { |
// TODO Auto-generated catch block |
e1.printStackTrace(); |
} |
if (t){ |
if (x) { |
JqqF2 f1 = new JqqF2(); |
|
this .setVisible( false ); |
f1.setVisible( true ); |
} else { |
new passworderror(); |
} |
} else { |
new look(); |
} |
} |
@Override |
public void mousePressed(MouseEvent e) { |
// TODO Auto-generated method stub |
} |
@Override |
public void mouseReleased(MouseEvent e) { |
// TODO Auto-generated method stub |
} |
@Override |
public void mouseEntered(MouseEvent e) { |
// TODO Auto-generated method stub |
} |
@Override |
public void mouseExited(MouseEvent e) { |
// TODO Auto-generated method stub |
} |
}; |
初级程序员
by: 代码王 发表于:2018-01-04 01:45:06 顶(0) | 踩(1) 回复
buqingc
回复评论