zhuce.java.svn-base
资源名称:QQ.rar [点击查看]
上传用户:hongdaled
上传日期:2007-10-03
资源大小:680k
文件大小:3k
源码类别:
ICQ/即时通讯
开发平台:
Java
- package client;
- import java.awt.Checkbox;
- import java.awt.CheckboxGroup;
- import java.awt.Color;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.Frame;
- import java.awt.Panel;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
- import java.net.Socket;
- import java.net.UnknownHostException;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- public class zhuce {
- StringBuffer sb;
- String ss;
- qq_user user;
- Frame f=new Frame("个人信息");
- //创建了一个Frame
- JPanel p1=new JPanel();
- JPanel p2=new JPanel();
- JPanel p4=new JPanel();
- JPanel p5=new JPanel();
- //创建了5个面板
- JLabel l1=new JLabel("qq姓名:");
- JLabel l2=new JLabel("性别");
- ;
- JLabel l5=new JLabel("你的信息");
- //创建了5个标签
- JTextField tf=new JTextField("",4);
- //创建了1个文本框用来输入姓名
- JTextArea ta=new JTextArea("",5,25);
- //创建了1个文本区用来显示个人信息
- CheckboxGroup cbr=new CheckboxGroup();
- Checkbox man=new Checkbox("男",false,cbr);
- Checkbox woman=new Checkbox("女",false,cbr);
- //创建了两个单选框
- //创建了1个列表框
- JButton b1=new JButton("提交");
- JButton b2=new JButton("确认");
- //创建了2个按钮
- Font font=new Font("宋体",Font.BOLD,20);
- //创建了字体font信息为:"宋体",加粗,15号
- private String[] pics = new String[] {//头像
- "1.jpg", "3.jpg",
- "5.jpg", "7.jpg"};
- Socket s;
- ObjectOutputStream ois;
- public zhuce(){
- f.setLayout(new FlowLayout());
- f.add(p1);
- f.add(p2);
- f.add(p4);
- f.add(p5);
- //frame上添加了5个面板
- p1.add(l1);
- p1.add(tf);
- p1.add(l2);
- p1.add(man);
- p1.add(woman);
- p4.add(l5);
- p4.add(ta);
- //p4面板上添加组件
- p5.add(b1);
- p5.add(b2);
- //p5面板上添加组件
- f.setSize(400, 400);
- //设置frame大小
- f.setVisible(true);
- b1.addMouseListener(new MouseAdapter(){
- public void mouseClicked(MouseEvent e) {
- user=new qq_user();
- user.info=ta.getText();
- user.name=tf.getText();
- if(man.getState()==true)
- user.sex=1;
- else
- user.sex=0;
- try {
- s=new Socket("127.0.0.1",8888);
- ois=new ObjectOutputStream(s.getOutputStream());
- ois.writeObject(user);
- f.setVisible(false);
- ois.close();
- s.close();
- } catch (UnknownHostException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- });
- b2.addMouseListener(new MouseAdapter(){
- public void mouseClicked(MouseEvent e) {
- System.exit(0);
- }
- });
- }
- }