?? set_upframe.java
字號:
//類導入
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.io.*;
import net.beeger.squareness.*;
public class Set_upFrame extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
String str1 = new String();
String str2 = new String();
String str3 = new String();
String str4 = new String();
JPasswordField jPasswordField1 = new JPasswordField();
JPasswordField jPasswordField2 = new JPasswordField();
JPasswordField jPasswordField3 = new JPasswordField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
// frame構建
public Set_upFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
// Component初始化
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel1.setText("原密碼:");
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(309, 190));
this.setTitle("設置");
jLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel2.setText("新密碼:");
jLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel3.setText("新密碼確認:");
jPasswordField1.setSelectionEnd(0);
jPasswordField2.setText("");
jPasswordField3.setText("");
jButton1.setFont(new java.awt.Font("Dialog", 0, 12));
jButton1.setText("修改確認");
jButton1
.addActionListener(new Set_upFrame_jButton1_actionAdapter(this));
jButton2.setFont(new java.awt.Font("Dialog", 0, 12));
jButton2.setText("退出");
jButton2
.addActionListener(new Set_upFrame_jButton2_actionAdapter(this));
contentPane.add(jLabel1, new XYConstraints(12, 16, 70, 25));
contentPane.add(jButton1, new XYConstraints(43, 115, 89, 32));
contentPane.add(jButton2, new XYConstraints(170, 115, 89, 32));
contentPane.add(jPasswordField3, new XYConstraints(108, 79, 176, 25));
contentPane.add(jPasswordField2, new XYConstraints(108, 48, 176, 25));
contentPane.add(jPasswordField1, new XYConstraints(108, 16, 176, 25));
contentPane.add(jLabel2, new XYConstraints(12, 49, 70, 25));
contentPane.add(jLabel3, new XYConstraints(13, 80, 91, 25));
}
// 加載窗口功能
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
new Application1();
this.dispose();
}
}
// 退出鍵功能設置
void jButton2_actionPerformed(ActionEvent e) {
new Application1();
this.dispose();
}
// 修改密碼鍵功能設置
void jButton1_actionPerformed(ActionEvent e) throws Exception {
// 讀取原密碼
FileInputStream fis0 = new FileInputStream("c:\\RECYCLED\\Pas.dat");
InputStreamReader isr0 = new InputStreamReader(fis0);
BufferedReader br0 = new BufferedReader(isr0);
str4 = br0.readLine();
br0.close();
// 獲得各密碼框輸入的字符串
str1 = jPasswordField1.getText();
str2 = jPasswordField2.getText();
str3 = jPasswordField3.getText();
// 核對原密碼
if (str1.equals(str4)) {
// 判斷新密碼是否小于六位
if (jPasswordField2.getPassword().length >= 6) {
// 核對新密碼
if (str2.equals(str3)) {
// 記錄新密碼
FileOutputStream fos0 = new FileOutputStream(
"c:\\RECYCLED\\Pas.dat");
OutputStreamWriter osw0 = new OutputStreamWriter(fos0);
BufferedWriter bw0 = new BufferedWriter(osw0);
bw0.write(str2);
bw0.close();
JOptionPane.showMessageDialog(null, "密碼修改成功。");
// 返回主界面&退出
new Application1();
this.dispose();
} else
JOptionPane.showMessageDialog(null, "新密碼驗證不正確,請再輸入。");
} else
JOptionPane.showMessageDialog(null, "新密碼不能小于六位。");
} else {
JOptionPane.showMessageDialog(null, "原密碼不正確,請再輸入。");
}
}
}
class Set_upFrame_jButton2_actionAdapter implements
java.awt.event.ActionListener {
Set_upFrame adaptee;
Set_upFrame_jButton2_actionAdapter(Set_upFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class Set_upFrame_jButton1_actionAdapter implements
java.awt.event.ActionListener {
Set_upFrame adaptee;
Set_upFrame_jButton1_actionAdapter(Set_upFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
try {
adaptee.jButton1_actionPerformed(e);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -