⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatemyinfo.java

📁 JAVAQQ 聊天系统,信息发送.改变头像.等功能,时时聊天.
💻 JAVA
字号:
package com.li.myqq.login;
import java.awt.*;

import javax.swing.*;

import com.li.myqq.server.LianJie;


import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.*;
import javax.swing.JButton;


public class UpdateMyInfo extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JLabel jLabel = null;

	public JTextField txtname = null;

	private JLabel jLabel3 = null;

	public JComboBox jComboBox = null;

	private JLabel jLabel4 = null;

	private JLabel jLabel5 = null;

	public JTextField email = null;

	public JComboBox jComboBox1 = null;

	private JLabel jLabel6 = null;

	public JComboBox jComboBox11 = null;

	private JLabel jLabel7 = null;

	public JComboBox jComboBox111 = null;

	private JLabel jLabel8 = null;

	private JButton submit = null;

	private JButton cexiao = null;

	private JButton cancel = null;
    private ImageIcon pic[]=new ImageIcon[11] ;  //  @jve:decl-index=0:

	private JLabel jLabel9 = null;

	private JTextArea jTextArea = null;
	String number=null;  //  @jve:decl-index=0:
	Socket socket;  //  @jve:decl-index=0:
	BufferedReader bur=null; 
	PrintWriter pw=null;

	/**
	 * This is the default constructor
	 */
	public UpdateMyInfo() {
		super();
	  this.socket=LianJie.socket;
	   
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
	
		this.setSize(494, 318);
		this.setResizable(false);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/pic/84.gif")));
		this.setContentPane(getJContentPane());
		this.setVisible(true);
		this.setTitle("个人信息修改");
		jComboBox.addItem("北京");
		jComboBox11.addItem("北京市");
		jComboBox1.addItem("男");
		jComboBox1.addItem("女");
		String pro[]={"北京","上海","广州","湖南","湖北","河北","山西","黑龙江","河南","江苏","贵州","安徽","福建"};
		for(int i=0;i<13;i++)
		{
			jComboBox.addItem(pro[i]);
		}
		
		try {
			bur=new BufferedReader(new InputStreamReader(socket.getInputStream()));
			pw=new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true);
		} catch (IOException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {			jLabel9 = new JLabel();
jLabel9.setBounds(new Rectangle(9, 193, 106, 29));
jLabel9.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
jLabel9.setHorizontalAlignment(SwingConstants.CENTER);
jLabel9.setText("个人说明:");
jLabel8 = new JLabel();
jLabel8.setBounds(new Rectangle(145, 7, 192, 38));
jLabel8.setHorizontalAlignment(SwingConstants.CENTER);
jLabel8.setFont(new Font("\u9ed1\u4f53", Font.BOLD, 24));
jLabel8.setText("个人信息修改");
jLabel7 = new JLabel();
jLabel7.setBounds(new Rectangle(291, 48, 76, 29));
jLabel7.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel7.setHorizontalAlignment(SwingConstants.CENTER);
jLabel7.setText("个人形 象:");
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(250, 127, 90, 26));
jLabel6.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel6.setHorizontalAlignment(SwingConstants.CENTER);
jLabel6.setText("地    区:");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(8, 160, 105, 28));
jLabel5.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel5.setHorizontalAlignment(SwingConstants.CENTER);
jLabel5.setText("E—Mail:");
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(9, 125, 103, 26));
jLabel4.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel4.setHorizontalAlignment(SwingConstants.CENTER);
jLabel4.setText("省   份:");
jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(8, 89, 102, 27));
			jLabel3.setHorizontalTextPosition(SwingConstants.CENTER);
			jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel3.setText("性   别:");
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(8, 51, 101, 28));
			jLabel.setHorizontalTextPosition(SwingConstants.CENTER);
			jLabel.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel.setText("*呢  称:");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.setBackground(new Color(4, 247, 17));
			jContentPane.add(jLabel, null);
			jContentPane.add(getTxtname(), null);
			jContentPane.add(jLabel3, null);
			jContentPane.add(getJComboBox(), null);
			jContentPane.add(jLabel4, null);
			jContentPane.add(jLabel5, null);
			jContentPane.add(getEmail(), null);
			jContentPane.add(getJComboBox1(), null);
			jContentPane.add(jLabel6, null);
			jContentPane.add(getJComboBox11(), null);
			jContentPane.add(jLabel7, null);
			jContentPane.add(getJComboBox111(), null);
			jContentPane.add(jLabel8, null);
			jContentPane.add(getSubmit(), null);
			jContentPane.add(getCexiao(), null);
			jContentPane.add(getCancel(), null);
			jContentPane.add(jLabel9, null);
			jContentPane.add(getJTextArea(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes txtname	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtname() {
		if (txtname == null) {
			txtname = new JTextField();
			txtname.setBounds(new Rectangle(133, 49, 144, 29));
		}
		return txtname;
	}

	/**
	 * This method initializes jComboBox	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox() {
		if (jComboBox == null) {
			jComboBox = new JComboBox();
			jComboBox.setBounds(new Rectangle(135, 125, 93, 27));
			jComboBox.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					 String flag=jComboBox.getSelectedItem().toString();
					 if(flag.equals("北京"))
					 {
						 jComboBox11.removeAllItems();
						 jComboBox11.addItem("北京市");
					 }
					 else if(flag.equals("湖南"))
					 {
						 jComboBox11.removeAllItems();
						 jComboBox11.addItem("岳阳");
						 jComboBox11.addItem("长沙");
						 jComboBox11.addItem("常德");
						 jComboBox11.addItem("怀化");
						 jComboBox11.addItem("娄底");
						 jComboBox11.addItem("株洲");
					 }
					 else if(flag.equals("湖北"))
					 {
						 jComboBox11.removeAllItems();
						 jComboBox11.addItem("武汉");
						 jComboBox11.addItem("荆门");
						 jComboBox11.addItem("黄石");
						 jComboBox11.addItem("赤壁");
						 jComboBox11.addItem("忠祥");
					 }
					 else if(flag.equals("河北"))
					 {
						 jComboBox11.removeAllItems();
						 jComboBox11.addItem("石家庄");
						
					 }
					 else if(flag.equals("山西"))
					 {
						 jComboBox11.removeAllItems();
						 jComboBox11.addItem("太原");
						 jComboBox11.addItem("大同");
						
					 }
					 else 
					 {
						 jComboBox11.removeAllItems();
						 jComboBox11.addItem(flag);
					 }
				}
			});
		}
		return jComboBox;
	}

	/**
	 * This method initializes email	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getEmail() {
		if (email == null) {
			email = new JTextField();
			email.setBounds(new Rectangle(134, 161, 277, 28));
		}
		return email;
	}

	/**
	 * This method initializes jComboBox1	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox1() {
		if (jComboBox1 == null) {
			jComboBox1 = new JComboBox();
			jComboBox1.setBounds(new Rectangle(136, 89, 91, 26));
		}
		return jComboBox1;
	}

	/**
	 * This method initializes jComboBox11	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox11() {
		if (jComboBox11 == null) {
			jComboBox11 = new JComboBox();
			jComboBox11.setBounds(new Rectangle(354, 125, 98, 28));
		}
		return jComboBox11;
	}

	
	private JComboBox getJComboBox111() {
		if (jComboBox111 == null) {
			jComboBox111 = new JComboBox();
			jComboBox111.setBounds(new Rectangle(377, 48, 64, 40));
			
			for(int i=1;i<pic.length;i++)
			{
				pic[i]=new ImageIcon("./pic/"+i+".gif");
				jComboBox111.addItem(pic[i]);
			}
		}
		return jComboBox111;
	}

	/**
	 * This method initializes submit	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getSubmit() {
		if (submit == null) {
			submit = new JButton();
			submit.setBounds(new Rectangle(62, 255, 80, 29));
			submit.setText("确定");
			submit.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
				
				     if(txtname.getText().equals("") )
				     {
				    	 JOptionPane.showMessageDialog(null, "带*号的为必填字段!");
				     }
				   
				    
				}
			});
			submit.addActionListener(new java.awt.event.ActionListener() {
				@SuppressWarnings({ "unchecked", "static-access" })
				public void actionPerformed(java.awt.event.ActionEvent e) {
				
					String name=txtname.getText().toString().trim();
					String sex=jComboBox1.getSelectedItem().toString();
					String address=jComboBox.getSelectedItem().toString()+"-"+jComboBox11.getSelectedItem().toString();
					@SuppressWarnings("unused")
					String e_mail=email.getText().toString().trim();
					String shuoming=jTextArea.getText().toString().trim();
					@SuppressWarnings("unused")
					int pic=jComboBox111.getSelectedIndex()+1;
					Integer mm=new Integer(pic);
					String xinxi[]={name,sex,address,e_mail,shuoming,mm.toString()};
					try {		
						
						
						pw.println("right");
						for(int i=0;i<6;i++)
						{
							System.out.println(xinxi[i]);
						    pw.println(xinxi[i]);
						}
				        String xin=bur.readLine();
				        String bf[]=xin.split("/");
				        Chuangkou.jLabel3.setText(bf[2].toString());
				        Chuangkou.jLabel4.setText(bf[0].toString());
				        Chuangkou.jLabel5.setText(bf[3].toString());
						ImageIcon icon=new ImageIcon("./pic/"+Integer.parseInt(bf[4])+".gif");
						Chuangkou.jLabel2.setIcon(icon);
						Login.main.setXinxi(bf);
					} catch (IOException e1) {
						// TODO 自动生成 catch 块
						e1.printStackTrace();
					}
				}
			});
		}
		return submit;
	}

	/**
	 * This method initializes cexiao	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCexiao() {
		if (cexiao == null) {
			cexiao = new JButton();
			cexiao.setBounds(new Rectangle(192, 253, 83, 30));
			cexiao.setText("重置");
			cexiao.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					txtname.setText("");
					txtname.requestFocus();
				
					email.setText("");
					jTextArea.setText("");
				}
			});
		}
		return cexiao;
	}

	/**
	 * This method initializes cancel	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCancel() {
		if (cancel == null) {
			cancel = new JButton();
			cancel.setBounds(new Rectangle(341, 254, 85, 30));
			cancel.setText("退出");
			cancel.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					UpdateMyInfo.this.dispose();
					
				}
			});
		}
		return cancel;
	}

	/**
	 * This method initializes jTextArea	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	public JTextArea getJTextArea() {
		if (jTextArea == null) {
			jTextArea = new JTextArea();
			jTextArea.setBounds(new Rectangle(134, 192, 276, 47));
		}
		return jTextArea;
	}

	public Socket getSocket() {
		return socket;
	}

	public void setSocket(Socket socket) {
		this.socket = socket;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

}  //  @jve:decl-index=0:visual-constraint="8,11"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -