📄 xiugaimimaframe.java
字号:
package com.zhou.view;
import java.awt.*;
import com.zhou.control.*;
import com.zhou.model.*;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
public class XiuGaiMiMaFrame extends JFrame {
Card card = new Card();
BackgroundImage jPanel1 = new BackgroundImage();
public XiuGaiMiMaFrame(Card card) {
this.card = card;
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
jPanel1.setImage("Image//444.jpg");
setSize(new Dimension(800, 600));
setTitle("修改密码");
jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 40));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel1.setText("修 改 密 码");
jLabel1.setBounds(new Rectangle(303, 40, 249, 45));
jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 25));
jLabel2.setText("原始密码:");
jLabel2.setBounds(new Rectangle(255, 137, 120, 35));
jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 25));
jLabel3.setText("新 密 码:");
jLabel3.setBounds(new Rectangle(255, 213, 120, 35));
jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 25));
jLabel4.setText("确认密码:");
jLabel4.setBounds(new Rectangle(255, 280, 120, 35));
jButton1.setBounds(new Rectangle(236, 400, 120, 40));
jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 30));
jButton1.setText("确 认");
jButton1.addActionListener(new XiuGaiMiMaFrame_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(554, 400, 120, 40));
jButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 30));
jButton2.setText("取 消");
jButton2.addActionListener(new XiuGaiMiMaFrame_jButton2_actionAdapter(this));
jButton3.setBounds(new Rectangle(398, 400, 120, 40));
jButton3.setFont(new java.awt.Font("宋体", Font.PLAIN, 30));
jButton3.setText("重 置");
jButton3.addActionListener(new XiuGaiMiMaFrame_jButton3_actionAdapter(this));
jPasswordField1.setBounds(new Rectangle(381, 134, 180, 35));
jPasswordField2.setBounds(new Rectangle(382, 208, 180, 35));
jPasswordField3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 25));
jPasswordField3.setBounds(new Rectangle(383, 275, 180, 35));
jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 25));
jLabel5.setForeground(Color.red);
jLabel5.setHorizontalAlignment(SwingConstants.CENTER);
jLabel5.setBounds(new Rectangle(241, 341, 438, 42));
jPanel1.setBounds(new Rectangle(0, 0, 800, 600));
jPanel1.setLayout(null);
this.getContentPane().add(jPanel1);
jPanel1.add(jLabel1);
jPanel1.add(jLabel5);
jPanel1.add(jButton3);
jPanel1.add(jButton2);
jPanel1.add(jButton1);
jPanel1.add(jPasswordField3);
jPanel1.add(jPasswordField2);
jPanel1.add(jPasswordField1);
jPanel1.add(jLabel4);
jPanel1.add(jLabel3);
jPanel1.add(jLabel2);
}
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JPasswordField jPasswordField1 = new JPasswordField();
JPasswordField jPasswordField2 = new JPasswordField();
JPasswordField jPasswordField3 = new JPasswordField();
JLabel jLabel5 = new JLabel();
public void jButton1_actionPerformed(ActionEvent e) {
jLabel5.setText("");
String pwd1 = String.valueOf(jPasswordField1.getPassword());
String pwd2 = String.valueOf(jPasswordField2.getPassword());
String pwd3 = String.valueOf(jPasswordField3.getPassword());
ConnectionDB db = new ConnectionDB(card);
String sql = "select *from card where userID='" + card.getUserID() +
"'and pwd='" + pwd1 + "'";
if (pwd1.equals("")) {
jLabel5.setText("请输入原密码!");
return;
}
if(pwd1.length() != 6){
jLabel5.setText("请正确输入原密码!");
return;
}
if(pwd1.equals(pwd2)){
jLabel5.setText("原密码不能和新密码一致!");
return;
}
if (pwd2.equals("")) {
jLabel5.setText("请输入新密码!");
return;
}
if (pwd2.length() != 6) {
jLabel5.setText("密码必须为六位数字!");
return;
}
if (pwd3.equals("")) {
jLabel5.setText("请输入确认密码!");
return;
}
if (pwd2.equals(pwd3)) {
if (db.getSelect(sql).size() != 0) {
String sql1 = "update card set pwd='" +
pwd3 +
"'where UserID='" + card.getUserID() + "'";
String sql2 = "update UserInformation set pwd='" +
pwd3
+ "'where UserID='" +
card.getUserID() + "'";
if (db.getUpdate(sql1) && db.getUpdate(sql2)) {
jLabel5.setText("修改密码成功!");
Open open = new Open(card);
this.dispose();
}
} else {
jLabel5.setText("请你输入正确的密码!");
}
} else {
jLabel5.setText("两次输入的密码不一致!");
}
}
public void jButton2_actionPerformed(ActionEvent e) {
Open open = new Open(card);
this.dispose();
}
public void jButton3_actionPerformed(ActionEvent e) {
jPasswordField1.setText("");
jPasswordField2.setText("");
jPasswordField3.setText("");
jLabel5.setText("");
}
}
class XiuGaiMiMaFrame_jButton3_actionAdapter implements ActionListener {
private XiuGaiMiMaFrame adaptee;
XiuGaiMiMaFrame_jButton3_actionAdapter(XiuGaiMiMaFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}
}
class XiuGaiMiMaFrame_jButton2_actionAdapter implements ActionListener {
private XiuGaiMiMaFrame adaptee;
XiuGaiMiMaFrame_jButton2_actionAdapter(XiuGaiMiMaFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class XiuGaiMiMaFrame_jButton1_actionAdapter implements ActionListener {
private XiuGaiMiMaFrame adaptee;
XiuGaiMiMaFrame_jButton1_actionAdapter(XiuGaiMiMaFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -