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

📄 zhece.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.awt.Dimension;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

public class Zhece extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;  //  @jve:decl-index=0:visual-constraint="37,10"

	private JLabel jLabel = null;

	public JTextField txtname = null;

	private JLabel jLabel1 = null;

	public JPasswordField pass = null;

	private JLabel jLabel2 = null;

	public JPasswordField pass1 = 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;
	
	Socket socket;  //  @jve:decl-index=0:
	PrintWriter pw=null;
	/**
	 * This is the default constructor
	 */
	public Zhece() {
		super();
	  this.socket=LianJie.socket;
	   
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
	
		this.setSize(494, 392);
		this.setResizable(false);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/pic/84.gif")));
		this.setContentPane(getJContentPane());
		this.setVisible(true);
		this.setTitle("QQ号码注册申请");
		jComboBox.addItem("北京");
		jComboBox11.addItem("北京市");
		jComboBox1.addItem("男");
		jComboBox1.addItem("女");
		String pro[]={"北京","上海","广州","湖南","湖北","河北","山西","黑龙江","河南","江苏","贵州","安徽","福建"};
		for(int i=0;i<13;i++)
		{
			jComboBox.addItem(pro[i]);
		}
		
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {			jLabel9 = new JLabel();
jLabel9.setBounds(new Rectangle(10, 264, 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(251, 198, 90, 26));
jLabel6.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel6.setHorizontalAlignment(SwingConstants.CENTER);
jLabel6.setText("地    区:");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(9, 231, 105, 28));
jLabel5.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel5.setHorizontalAlignment(SwingConstants.CENTER);
jLabel5.setText("E—Mail:");
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(10, 196, 103, 26));
jLabel4.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel4.setHorizontalAlignment(SwingConstants.CENTER);
jLabel4.setText("省   份:");
jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(9, 160, 102, 27));
			jLabel3.setHorizontalTextPosition(SwingConstants.CENTER);
			jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel3.setText("性   别:");
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(8, 121, 101, 28));
			jLabel2.setHorizontalTextPosition(SwingConstants.CENTER);
			jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel2.setText("*密码确认:");
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(8, 87, 101, 24));
			jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
			jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel1.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.setSize(new Dimension(453, 363));
			jContentPane.add(jLabel, null);
			jContentPane.add(getTxtname(), null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(getPass(), null);
			jContentPane.add(jLabel2, null);
			jContentPane.add(getPass1(), 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 pass	
	 * 	
	 * @return javax.swing.JPasswordField	
	 */
	private JPasswordField getPass() {
		if (pass == null) {
			pass = new JPasswordField();
			pass.setBounds(new Rectangle(135, 89, 140, 25));
		}
		return pass;
	}

	/**
	 * This method initializes pass1	
	 * 	
	 * @return javax.swing.JPasswordField	
	 */
	private JPasswordField getPass1() {
		if (pass1 == null) {
			pass1 = new JPasswordField();
			pass1.setBounds(new Rectangle(134, 122, 140, 29));
		}
		return pass1;
	}

	/**
	 * This method initializes jComboBox	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox() {
		if (jComboBox == null) {
			jComboBox = new JComboBox();
			jComboBox.setBounds(new Rectangle(136, 196, 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(135, 232, 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(137, 160, 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(355, 196, 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(58, 324, 80, 29));
			submit.setText("提交");
			submit.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
				    
				     if(txtname.getText().equals("") || pass.getText().equals("") ||pass1.getText().equals(""))
				     {
				    	 JOptionPane.showMessageDialog(null, "带*号的为必填字段!");
				     }
				     else if(!pass.getText().trim().equals(pass1.getText().trim()))
				     {
				    	
				    	 JOptionPane.showMessageDialog(null, "密码输入不一致!");
				     }
				     else 
				     {    
				    	try {
						    pw=new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true);
							pw.println("success");
							String name=txtname.getText().toString().trim();
							String mima=pass.getText().toString().trim();
							String sex=jComboBox1.getSelectedItem().toString();
							String address=jComboBox.getSelectedItem().toString()+"-"+jComboBox11.getSelectedItem().toString();
							String e_mail=email.getText().toString().trim();
							String shuoming=jTextArea.getText().toString().trim();
							int pic=jComboBox111.getSelectedIndex()+1;
							pw.println(name);
							pw.println(mima);
							pw.println(sex);
							pw.println(address);
							pw.println(e_mail);
							pw.println(shuoming);
							pw.println(pic);
						} catch (IOException e1) {
						
							pw.println("fail");
						}
				    	 
				     }
				     
				}
			});
		}
		return submit;
	}

	/**
	 * This method initializes cexiao	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCexiao() {
		if (cexiao == null) {
			cexiao = new JButton();
			cexiao.setBounds(new Rectangle(192, 324, 83, 30));
			cexiao.setText("重置");
			cexiao.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					txtname.setText("");
					txtname.requestFocus();
					pass.setText("");
					pass1.setText("");
					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(323, 322, 85, 32));
			cancel.setText("退出");
			cancel.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					Zhece.this.dispose();
					new Login();
				}
			});
		}
		return cancel;
	}

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

	public Socket getSocket() {
		return socket;
	}

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

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

⌨️ 快捷键说明

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