?? modifypass.java
字號:
package com.client ;
import java.io.* ;
import java.net.* ;
import java.sql.* ;
import javax.swing.* ;
import java.awt.event.*;
import java.awt.* ;
import java.util.*;
public class ModifyPass extends JFrame implements ActionListener{
private Socket s ;
private String u ;
public void setSocket(Socket s , String u ){
this.s = s ;
this.u = u ;
}
JPasswordField t_pass = new JPasswordField() ;
JPasswordField t_rpass = new JPasswordField() ;
ModifyPass(){
this.setSize(300 , 200) ;
JLabel l_pass = new JLabel("新密碼") ;
JLabel l_rpass = new JLabel("確認新密碼") ;
JButton b_modify = new JButton("修改") ;
b_modify.addActionListener(this) ;
JPanel p1 = new JPanel() ;
p1.setLayout(new GridLayout(2 , 2)) ;
p1.add(l_pass) ;
p1.add(t_pass) ;
p1.add(l_rpass) ;
p1.add(t_rpass) ;
JPanel p2 = new JPanel() ;
p2.setLayout(new FlowLayout()) ;
p2.add(b_modify) ;
this.setLayout(new BorderLayout()) ;
this.add(p1 , BorderLayout.CENTER) ;
this.add(p2 , BorderLayout.SOUTH) ;
this.setVisible(true) ;
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("修改")){
if(!t_pass.getText().equals(t_rpass.getText())){
javax.swing.JOptionPane op = new JOptionPane() ;
op.showMessageDialog(this , "密碼不一致,請重新輸入!") ;
t_pass.setText("") ;
t_rpass.setText("") ;
}else{
try {
OutputStream os = s.getOutputStream() ;
OutputStreamWriter osw = new OutputStreamWriter(os) ;
PrintWriter pw = new PrintWriter(osw , true) ;
pw.println("modifypass%"+u+"%"+t_pass.getText()) ;
}
catch (Exception ex) {
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -