8.ClientChatGroupWindow类[code=java]package util.doTask;
import util.ClientMainWindow;
public class ClientChatGroupWindow extends ClientMainWindow {
}[/code]9.ClientChatWindow类[code=java]package util.doTask;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import javax.swing.*;
import util.ClientMainWindow;
public class ClientChatWindow extends ClientMainWindow {
private String friendName;
private String nickName;
private JScrollPane showPane;
private JTextArea showArea;
private JScrollPane sendPane;
private JTextArea sendArea;
private JButton send;
private JButton close;
public ClientChatWindow(String friendName,String nickName){
this.friendName = friendName;
this.nickName = nickName;
init();
}
public void init(){
this.setTitle(" 与 "+nickName+"("+friendName+")"+" 聊天中 ");
this.setBounds(250,100,450,425);
this.setResizable(false);
this.setLayout(null);
showArea = new JTextArea();
showArea.setEditable(false);
showPane = new JScrollPane(showArea);
showPane.setBounds(15,10,415,250);
this.add(showPane);
sendArea = new JTextArea();
sendPane = new JScrollPane(sendArea);
sendPane.setBounds(15,265,415,100);
this.add(sendPane);
close = new JButton("关 闭");
close.setBounds(270,370,70,20);
close.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
exit();
}
});
this.add(close);
send = new JButton("发 送");
send.setBounds(350,370,70,20);
send.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
if(sendArea.getText().trim().equals("")) return;
send("5"+userName+"("+friendName+")"+mySecondName+" "+new Date().toLocaleString().substring(10)+"\n"+sendArea.getText());
showArea.append(mySecondName+" "+new Date().toLocaleString().substring(10)+"\n"+sendArea.getText()+"\n");
sendArea.setText("");
}
});
this.add(send);
this.setVisible(true);
this.validate();
}
public void doGet(String msg){
showArea.append(msg+"\n");
}
public void exit(){
ClientChatWindow c= (ClientChatWindow)chat.get("friendName");
c=null;
chat.remove(friendName);
this.dispose();
}
}[/code]10.ClientCheckRecall类[code=java]package util.doTask;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import util.ClientMainWindow;
public class ClientCheckRecall extends ClientMainWindow {
public ClientCheckRecall(){
MyInfoInit();
}
public void MyInfoInit(){
this.setBounds(300,100,300,400);
this.setLayout(null);
this.setTitle("聊天记录");
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
exit();
}
});
this.setVisible(true);
this.validate();
}
public void exit(){
ccr = null ;
this.dispose();
}
}[/code]11.ClientShowFriendInfo类[code=java]package util.doTask;
import java.awt.event.*;
import java.io.IOException;
import java.net.Socket;
import java.util.*;
import javax.swing.*;
import util.ClientMainWindow;
public class ClientShowFriendInfo extends ClientMainWindow {
private String userName;
private boolean bool=false;
private JLabel name;
private JLabel name_value;
private JLabel nickName;
private JLabel nickName_value;
private JLabel sex;
private JLabel sex_value;
private JLabel age;
private JLabel age_value;
private JLabel birthday;
private JLabel birthday_value;
private JLabel trueName;
private JLabel trueName_value;
private JLabel address;
private JLabel address_value;
private JLabel description;
private JLabel description_value;
private JLabel sign;
private JLabel sign_value;
private JButton add;
private JButton exit;
public ClientShowFriendInfo(String name,boolean b) {
userName = name;
bool = b;
friendInfoInit();
}
public void friendInfoInit(){
this.setBounds(300,100,300,230);
this.setLayout(null);
this.setResizable(false);
this.setTitle("好友资料");
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
exit();
}
});
name = new JLabel("用户名:");
name.setBounds(10,10,50,20);
this.add(name);
name_value = new JLabel(userName);
name_value.setBounds(50,10,100,20);
this.add(name_value);
nickName = new JLabel("呢 称:");
nickName.setBounds(150,10,50,20);
this.add(nickName);
nickName_value = new JLabel();
nickName_value.setBounds(190,10,100,20);
this.add(nickName_value);
sex = new JLabel("性 别:");
sex.setBounds(10,40,50,20);
this.add(sex);
sex_value = new JLabel();
sex_value.setBounds(50,40,20,20);
this.add(sex_value);
age = new JLabel("年 龄:");
age.setBounds(80,40,50,20);
this.add(age);
age_value = new JLabel();
age_value.setBounds(115,40,20,20);
this.add(age_value);
birthday = new JLabel("生 日:");
birthday.setBounds(150,40,50,20);
this.add(birthday);
birthday_value = new JLabel();
birthday_value.setBounds(190,40,100,20);
this.add(birthday_value);
trueName = new JLabel("真实姓名:");
trueName.setBounds(10,70,60,20);
this.add(trueName);
trueName_value = new JLabel();
trueName_value.setBounds(65,70,60,20);
this.add(trueName_value);
address = new JLabel("所在地:");
address.setBounds(130,70,50,20);
this.add(address);
address_value = new JLabel();
address_value.setBounds(170,70,90,20);
this.add(address_value);
description = new JLabel("自我描述:");
description.setBounds(10,100,60,20);
this.add(description);
description_value = new JLabel();
description_value.setBounds(65,100,150,20);
this.add(description_value);
sign = new JLabel("个性签名:");
sign.setBounds(10,130,60,20);
this.add(sign);
sign_value = new JLabel();
sign_value.setBounds(65,130,150,20);
this.add(sign_value);
add = new JButton("添加好友");
add.setBounds(10,160,100,20);
add.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
if(name_value.getText().equals("")||name_value.getText().equals(ClientMainWindow.userName))
return;
try {
dos.writeUTF('a'+name_value.getText());
} catch (IOException e) {
e.printStackTrace();
}
}
});
add.setVisible(bool);
this.add(add);
exit = new JButton("关 闭");
exit.setBounds(120,160,80,20);
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
exit();
}
});
this.add(exit);
this.setVisible(true);
this.validate();
}
public void exit(){
csfi = null;
this.dispose();
}
public void alert(String num){
if(num.equals("1")){
JOptionPane.showMessageDialog(this, "添加成功!");
return;
}
if(num.equals("0")){
JOptionPane.showMessageDialog(this, "添加失败!");
return;
}
}
public void setInfo(String msg){
String temp = msg;
if(msg.length()==0){
JOptionPane.showMessageDialog(this, "抱歉,该用户不存在");
exit();
return;
}
String nickName = temp.substring(2,Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
nickName_value.setText(nickName);
temp = temp.substring(Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
String sex = temp.substring(2,Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
sex_value.setText(sex);
temp = temp.substring(Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
String age = temp.substring(2,Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
age_value.setText(age);
temp = temp.substring(Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
String birthday = temp.substring(2,Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
if(!birthday.equals(""))
birthday_value.setText(birthday.substring(0,2)+" 月"+birthday.substring(2)+" 日");
temp = temp.substring(Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
String trueName = temp.substring(2,Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
trueName_value.setText(trueName);
temp = temp.substring(Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
String address = temp.substring(2,Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
address_value.setText(address);
temp = temp.substring(Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
String description = temp.substring(2,Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
description_value.setText(description);
temp = temp.substring(Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
String sign = temp.substring(2,Integer.parseInt(String.valueOf(temp.charAt(0)))+2);
sign_value.setText(sign);
}
}[/code] |
|