12.ClientShowGroupInfo类[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 ClientShowGroupInfo extends ClientMainWindow {
private String groupID;
private boolean bool=false;
private JLabel name;
private JLabel name_value;
private JLabel nickName;
private JLabel nickName_value;
private JLabel sex_value;
private JLabel age_value;
private JLabel birthday_value;
private JLabel trueName;
private JLabel trueName_value;
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 ClientShowGroupInfo(String name,boolean b) {
groupID = 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(groupID);
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);
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);
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(""))
return;
try {
dos.writeUTF("addGroup"+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(){
csgi = 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] |
|