📄 changpsw.java
字号:
package soft1;
import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import soft1Method.*;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Changpsw extends JDialog {
JLabel jLabel1 = new JLabel();
XYLayout xYLayout2 = new XYLayout();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
Dataset2 dt=new Dataset2();
GetValue gv=new GetValue();
public Changpsw(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public Changpsw() {
this(new Frame(), "Changpsw", true);
}
private void jbInit() throws Exception {
jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
jLabel1.setText("修改密码");
this.getContentPane().setLayout(xYLayout2);
this.getContentPane().setBackground(new Color(197, 205, 234));
this.setTitle("修改密码");
jButton4.addActionListener(new Changpsw_jButton4_actionAdapter(this));
jLabel4.setText("重新输入新密码:");
jLabel3.setText("新密码:");
jLabel2.setNextFocusableComponent(jTextField2);
jLabel2.setText("当前密码:");
jButton5.setText("重置");
jButton5.addActionListener(new Changpsw_jButton5_actionAdapter(this));
jButton4.setNextFocusableComponent(jButton5);
jButton4.setText("确认");
jTextField3.setNextFocusableComponent(jButton4);
jTextField2.setNextFocusableComponent(jTextField3);
xYLayout2.setWidth(280);
xYLayout2.setHeight(256);
this.getContentPane().add(jLabel1, new XYConstraints(96, 0, 88, 38));
this.getContentPane().add(jLabel2, new XYConstraints(18, 48, 84, 29));
this.getContentPane().add(jTextField1,
new XYConstraints(118, 48, 146, 29));
this.getContentPane().add(jTextField2,
new XYConstraints(118, 93, 146, 29));
this.getContentPane().add(jTextField3,
new XYConstraints(118, 139, 146, 29));
this.getContentPane().add(jLabel3, new XYConstraints(18, 93, 84, 29));
this.getContentPane().add(jLabel4, new XYConstraints(12, 139, 106, 29));
this.getContentPane().add(jButton5, new XYConstraints(148, 186, 64, 29));
this.getContentPane().add(jButton4, new XYConstraints(49, 186, 64, 29));
}
public void jButton5_actionPerformed(ActionEvent e) {
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
public void jButton4_actionPerformed(ActionEvent e) throws
HeadlessException, SQLException, ClassNotFoundException {
//System.out.println(rs.getString("Password"));
if(jTextField1.getText().equals(""))
{JOptionPane.showMessageDialog(this,"请输入旧密码!","提示",JOptionPane.PLAIN_MESSAGE);}
else if(jTextField2.getText().equals(""))
{JOptionPane.showMessageDialog(this,"请输入新密码!","提示",JOptionPane.PLAIN_MESSAGE);}
else if(!jTextField2.getText().equals(jTextField3.getText()))
{JOptionPane.showMessageDialog(this,"两次新密码输入不匹配!","提示",JOptionPane.PLAIN_MESSAGE);}
else {
String s2="Select * from User Where Name='"+gv.Getvalue()+"' and Password='"+jTextField1.getText()+"'";
System.out.println(s2);
System.out.println(dt.Rs(s2).next());
if(!dt.Rs(s2).next()){
System.out.println(s2);
JOptionPane.showMessageDialog(this,"您输入的旧密码不正确!请重新输入!","提示",JOptionPane.ERROR_MESSAGE);
jTextField1.setText("");
}
else {
String s="Update User SET Password='"+jTextField2.getText()+"'WHERE Name='"+gv.Getvalue()+"'";
dt.Update(s);
System.out.println(s);
JOptionPane.showMessageDialog(this,"修改成功!","提示",JOptionPane.PLAIN_MESSAGE);
this.setVisible(false);
} }
}
}
class Changpsw_jButton4_actionAdapter implements ActionListener {
private Changpsw adaptee;
Changpsw_jButton4_actionAdapter(Changpsw adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
try {
adaptee.jButton4_actionPerformed(e);
} catch (ClassNotFoundException ex) {
} catch (SQLException ex) {
} catch (HeadlessException ex) {
}
}
}
class Changpsw_jButton5_actionAdapter implements ActionListener {
private Changpsw adaptee;
Changpsw_jButton5_actionAdapter(Changpsw adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton5_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -