📄 cpassword.java
字号:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
/**
* Modify JIDX Client user's self password.<p>
* 2005.9.20
* @version 0.1.2
* @author Daxin Tian
*
*/
class Cpassword extends Frame implements ActionListener
{
/**
* Label "Modify password".
*/
JLabel la1;
/**
* Label "Old Password".
*/
JLabel la2;
/**
* Label "New Password".
*/
JLabel la3;
/**
* Label "Confirm Password".
*/
JLabel la4;
/**
* Input old password.
*/
JPasswordField tf_old;
/**
* Input new password.
*/
JPasswordField tf_new;
/**
* Input confirm password.
*/
JPasswordField tf_confirm;
/**
* Button OK. When clicked perform modify action.
*/
JButton b_ok;
/**
* Button Cancel. When clicked close this window.
*/
JButton b_cancel;
/**
* Point to CmainFrame's c_dis.
*/
DataInputStream c_dis=null;
/**
* Point to CmainFrame's c_dos.
*/
DataOutputStream c_dos=null;
/**
* This JIDX Client's self username.
*/
String c_name=null;
/**
* Prompt error message when new password is not equal confirm password.
*/
MsgDialog msg=new MsgDialog();
/**
*
* @param dis CmainFrame's c_dis.
* @param dos CmainFrame's c_dos.
* @param name This JIDX Client's self username.
*/
Cpassword(DataInputStream dis,DataOutputStream dos,String name)
{
super("JIDX Client Password");
c_dis=dis;
c_dos=dos;
c_name=name;
setBounds(250,100,200,200);
JPanel p1,p2,p3,p4;
la1=new JLabel("Modify password",JLabel.CENTER);
la1.setBackground(Color.lightGray);
la2=new JLabel("Old Password",JLabel.RIGHT);
la3=new JLabel("New Password",JLabel.RIGHT);
la4=new JLabel("Confirm Password",JLabel.RIGHT);
tf_old=new JPasswordField(10);
tf_old.setEchoChar('*');
tf_new=new JPasswordField(10);
tf_new.setEchoChar('*');
tf_confirm=new JPasswordField(10);
tf_confirm.setEchoChar('*');
b_ok=new JButton("OK");
b_cancel=new JButton("Cancel");
setLayout(new GridLayout(5,1));
add(la1);
p1=new JPanel();
p1.setLayout(new GridLayout(1,2));
p1.add(la2);
p1.add(tf_old);
add(p1);
p2=new JPanel();
p2.setLayout(new GridLayout(1,2));
p2.add(la3);
p2.add(tf_new);
add(p2);
p3=new JPanel();
p3.setLayout(new GridLayout(1,2));
p3.add(la4);
p3.add(tf_confirm);
add(p3);
p4=new JPanel();
p4.setLayout(new GridLayout(1,2));
p4.add(b_ok);
p4.add(b_cancel);
add(p4);
pack();
b_ok.addActionListener(this);
b_cancel.addActionListener(this);
setVisible(false);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{setVisible(false);}
}
);
}
/**
* Listen button OK,Cancel's action.
*/
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b_ok)
{
if(tf_old.getText().trim().equals(""))
{
msg.show("Old password can't be null");
}
else
{
if(tf_new.getText().trim().equals(""))
{
msg.show("new password can't be null");
}
else
{
if(tf_confirm.getText().trim().equals(""))
{
msg.show("Confirm password can't be null");
}
else
{
if(!tf_new.getText().trim().equals(tf_confirm.getText().trim()))
{
msg.show("new password and confirm password doesn't equal");
}
else
{
StringBuffer c_sb=new StringBuffer();
c_sb.append("<msg><mod_password><name>"+c_name+"</name><oldpassword>"+tf_old.getText().trim()+"</oldpassword><newpassword>"+tf_new.getText().trim()+"</newpassword></mod_password></msg>");
try
{
//System.out.println("send mod: "+c_sb.toString());
c_dos.writeUTF(c_sb.toString());
la1.setText("Modifing Password......");
}
catch(IOException ee)
{
}
}
}
}
}
}
if(e.getSource()==b_cancel)
{
setVisible(false);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -