?? passwordedit_frame.java~13~
字號(hào):
package xscjgl;
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.awt.BorderLayout;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.sql.ResultSet;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import xscjgl.Jdbcconn;
import java.awt.Font;
/**
* <p>Title: java xscjgl</p>
*
* <p>Description:學(xué)生查成績,管理員輸成績、管理。二種權(quán)限的學(xué)生成績管理系統(tǒng) </p>
*
* <p>Copyright: lixing (c) 2006</p>
*
*
* @author 04級(jí)計(jì)算機(jī)教育班 黎興
* @version 1.0
*/
public class PasswordEdit_Frame extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel1 = new JLabel();
XYLayout xYLayout2 = new XYLayout();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JPasswordField jPasswordField1 = new JPasswordField();
JPasswordField jPasswordField2 = new JPasswordField();
JPasswordField jPasswordField3 = new JPasswordField();
String BeforeUno;
TitledBorder titledBorder1 = new TitledBorder("");
JLabel jLabel4 = new JLabel();
public PasswordEdit_Frame() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(xYLayout1);
this.setTitle("修改密碼窗體");
this.getContentPane().setBackground(new Color(66, 168, 227));
this.setForeground(Color.lightGray);
jPanel1.setBackground(new Color(241, 249, 249));
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel1.setLayout(xYLayout2);
jButton1.setText("提交");
jButton1.addActionListener(new
PasswordEdit_Frame_jButton1_actionAdapter(this));
jButton2.setText("退出");
jButton2.addActionListener(new
PasswordEdit_Frame_jButton2_actionAdapter(this));
jLabel1.setText("請(qǐng)輸入原密碼:");
jLabel2.setText("請(qǐng)輸入新密碼:");
jLabel3.setText("再次輸入新密碼:");
xYLayout1.setWidth(369);
xYLayout1.setHeight(257);
jLabel4.setFont(new java.awt.Font("宋體", Font.BOLD, 16));
jLabel4.setText("修改密碼");
jPanel1.add(jLabel1, new XYConstraints(44, 14, 97, 24));
jPanel1.add(jPasswordField1, new XYConstraints(167, 14, 114, -1));
jPanel1.add(jLabel2, new XYConstraints(44, 53, 96, -1));
jPanel1.add(jLabel3, new XYConstraints(43, 86, 111, -1));
jPanel1.add(jPasswordField2, new XYConstraints(167, 46, 112, -1));
jPanel1.add(jPasswordField3, new XYConstraints(167, 81, 110, -1));
this.getContentPane().add(jLabel4, new XYConstraints(143, 5, 85, 24));
this.getContentPane().add(jButton1, new XYConstraints(89, 189, -1, -1));
this.getContentPane().add(jButton2, new XYConstraints(217, 189, -1, -1));
this.getContentPane().add(jPanel1, new XYConstraints(12, 41, 329, 140));
}
public void jButton2_actionPerformed(ActionEvent e) {
dispose();
}
public void jButton1_actionPerformed(ActionEvent e) {
String BeforePassword = jPasswordField1.getText().trim().toString();
String NewPassword = jPasswordField2.getText().trim().toString();
String AgainPassword = jPasswordField3.getText().trim().toString();
if (BeforePassword.equals("") || NewPassword.equals("") ||
AgainPassword.equals(""))
{
JOptionPane.showMessageDialog(null, "密碼不能為空,請(qǐng)按要求輸入!");
} else {
//******************************************************************************
//判斷原密碼是否正確
try{
Jdbcconn conn = new Jdbcconn();
conn.OpenConn("tqti","tqti","111111");
String strSQL = "select * from UserTable where Uno='" +
BeforeUno + "'";
ResultSet rs = conn.getResults(strSQL);
rs.first();
String Upassword=rs.getString("Upwd");
if(Upassword.equals(BeforePassword))
{
//驗(yàn)證新密碼。
if(NewPassword.equals(AgainPassword))
{
//密碼驗(yàn)證成功。更新密碼。
try{
conn.executeUpdate("update UserTable set Upwd='"+NewPassword+"' where Uno='"+BeforeUno+"'");
System.out.println("update SQL is : update UserTable set Upwd='"+NewPassword+"' where Uno='"+BeforeUno+"'");
JOptionPane.showMessageDialog(null, "密碼修改成功,請(qǐng)牢記您的新密碼");
dispose();
conn.closeStmt();
conn.closeConn();
}catch(Exception ex)
{
JOptionPane.showMessageDialog(null, "密碼修改失敗,請(qǐng)重試!");
System.out.println(ex.getMessage());
}
}else{
JOptionPane.showMessageDialog(null, "兩次新密碼不一致,請(qǐng)重新輸入!");
jPasswordField2.setText("");
jPasswordField3.setText("");
}
}else{
JOptionPane.showMessageDialog(null, "原密碼錯(cuò)誤,請(qǐng)輸入正確的原始密碼!");
jPasswordField1.setText("");
}
}catch(Exception ex)
{
JOptionPane.showMessageDialog(null, "first exception has catched!");
System.out.println(ex.getMessage());
}
}
}
public static void main(String args[]){
PasswordEdit_Frame passwordFrame = new PasswordEdit_Frame();
passwordFrame.setVisible(true);
passwordFrame.setLocationRelativeTo(null);
}
}
class PasswordEdit_Frame_jButton1_actionAdapter implements ActionListener {
private PasswordEdit_Frame adaptee;
PasswordEdit_Frame_jButton1_actionAdapter(PasswordEdit_Frame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class PasswordEdit_Frame_jButton2_actionAdapter implements ActionListener {
private PasswordEdit_Frame adaptee;
PasswordEdit_Frame_jButton2_actionAdapter(PasswordEdit_Frame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -