4.ClientAddFriend类[code=java]package util.doTask;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.*;
import util.ClientMainWindow;
public class ClientAddFriend extends ClientMainWindow {
private JLabel name_label;
private JTextField name_value;
private JButton find;
private JButton exit;
public ClientAddFriend(){
addInit();
}
public void addInit(){
this.setBounds(380,260,200,150);
this.setLayout(null);
this.setResizable(false);
this.setTitle("添加好友");
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
exit();
}
});
name_label = new JLabel("用户名:");
name_label.setBounds(20,30,50,25);
this.add(name_label);
name_value = new JTextField(20);
name_value.setBounds(80,30,100,25);
this.add(name_value);
find = new JButton("查看");
find.setBounds(30, 80,70,25);
find.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
String friendName = name_value.getText();
if(friendName.equals("")) return;
showCheckFriend(friendName,true);
}
});
this.add(find);
exit = new JButton("关闭");
exit.setBounds(110,80,70,25);
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
exit();
}
});
this.add(exit);
this.setVisible(true);
this.validate();
}
public void exit(){
caf =null;
this.dispose();
}
}[/code]5.ClientAddGroup类[code=java]package util.doTask;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.*;
import util.ClientMainWindow;
public class ClientAddGroup extends ClientMainWindow {
private JLabel name_label;
private JTextField name_value;
private JButton find;
private JButton exit;
public ClientAddGroup(){
addInit();
}
public void addInit(){
this.setBounds(380,260,200,150);
this.setLayout(null);
this.setResizable(false);
this.setTitle("添加聊天群");
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
exit();
}
});
name_label = new JLabel("群号:");
name_label.setBounds(20,30,50,25);
this.add(name_label);
name_value = new JTextField(20);
name_value.setBounds(80,30,100,25);
this.add(name_value);
find = new JButton("查看");
find.setBounds(30, 80,70,25);
find.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
String groupID = name_value.getText();
if(groupID.equals("")) return;
showCheckGroup(groupID,true);
}
});
this.add(find);
exit = new JButton("关闭");
exit.setBounds(110,80,70,25);
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
exit();
}
});
this.add(exit);
this.setVisible(true);
this.validate();
}
public void exit(){
cag =null;
this.dispose();
}
}[/code]6.ClientChangePassword类[code=java]package util.doTask;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.swing.*;
import util.ClientMainWindow;
public class ClientChangePassword extends ClientMainWindow {
private JLabel old;
private JPasswordField old_value;
private JLabel news;
private JPasswordField news_value;
private JLabel news_1;
private JPasswordField news_1_value;
private JButton submit;
private JButton exit;
public ClientChangePassword(){
MyInfoInit();
}
public void MyInfoInit(){
this.setBounds(300,100,300,200);
this.setLayout(null);
this.setTitle("修改密码");
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
exit();
}
});
old = new JLabel("原密码:");
old.setBounds(30,20,60,25);
this.add(old);
old_value = new JPasswordField(20);
old_value.setBounds(100,20,120,25);
this.add(old_value);
news = new JLabel("新密码:");
news.setBounds(30,60,60,25);
this.add(news);
news_value = new JPasswordField(20);
news_value.setBounds(100,60,120,25);
this.add(news_value);
news_1 = new JLabel("确认密码:");
news_1.setBounds(30,90,60,25);
this.add(news_1);
news_1_value = new JPasswordField(20);
news_1_value.setBounds(100,90,120,25);
this.add(news_1_value);
submit = new JButton("确 定");
submit.setBounds(60,135,70,25);
submit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
if(String.valueOf(old_value.getPassword()).length()<6||String.valueOf(old_value.getPassword()).length()>16){
alert("原密码不正确!");
return;
}
if(String.valueOf(news_value.getPassword()).length()<6||String.valueOf(news_value.getPassword()).length()>16){
alert("新密码长度应该再6到16之间!");
return;
}
if(!String.valueOf(news_1_value.getPassword()).equals(String.valueOf(news_value.getPassword()))){
alert("两次密码不一致!");
return;
}
try {
dos.writeUTF("c"+String.valueOf(old_value.getPassword()).length()+";"+String.valueOf(old_value.getPassword())+String.valueOf(news_value.getPassword()));
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
this.add(submit);
exit = new JButton("关 闭");
exit.setBounds(135,135,70,25);
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
exit();
}
});
this.add(exit);
this.setVisible(true);
this.validate();
}
public void exit(){
ccp =null;
this.dispose();
}
}[/code] |
|