Instant Internal Chat program--register

Source: Internet
Author: User
Tags gettext
Package Z0929;
Import Java.awt.BorderLayout;
Import Java.awt.FlowLayout;
Import Java.awt.GridLayout;
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;
Import java.io.IOException;
Import Java.io.InputStream;
Import Java.io.OutputStream;
Import Java.net.Socket;

Import java.net.UnknownHostException;
Import Javax.swing.JButton;
Import Javax.swing.JFrame;
Import Javax.swing.JLabel;
Import Javax.swing.JOptionPane;
Import Javax.swing.JPanel;
Import Javax.swing.JPasswordField;

Import Javax.swing.JTextField;
	public class Zhuce extends JFrame {private JLabel usernamejlabal;
	Private JLabel Passwordjlabal;
	Private JLabel Repasswordjlabal;
	Private JTextField Usernamefield;
	Private JPasswordField Passwordfield;
	Private JPasswordField Repasswordfield;
	Private JButton zhuce;

	Private JButton Fanhui;
		Public Zhuce () {settitle ("User registration");
		SetSize (440, 340);
		Setlocationrelativeto (NULL);
		Setdefaultcloseoperation (2);
		Setresizable (FALSE);
	Setundecorated (FALSE);	
		Usernamejlabal = new JLabel ("account");

		Passwordjlabal = new JLabel ("password");
		Repasswordjlabal = new JLabel ("Confirm password");
		Usernamefield = new JTextField ();
		Passwordfield = new JPasswordField ();
		Repasswordfield = new JPasswordField ();
		Zhuce = new JButton ("complete registration");
		Fanhui =new JButton ("return login");
		JPanel JP = new JPanel ();
		Jp.setlayout (New GridLayout (0, 2));
		Jp.add (New JLabel (""));
		Jp.add (New JLabel (""));
		Jp.add (Usernamejlabal);	
		Jp.add (Usernamefield);
		Jp.add (New JLabel (""));
		Jp.add (New JLabel (""));
		Jp.add (Passwordjlabal);	
		Jp.add (Passwordfield);
		Jp.add (New JLabel (""));
		Jp.add (New JLabel (""));
		Jp.add (Repasswordjlabal);
		Jp.add (Repasswordfield);
		Jp.add (New JLabel (""));

		Jp.add (New JLabel (""));
		JPanel jp2=new JPanel ();
		Jp2.setlayout (New FlowLayout ());
		Jp2.add (Zhuce);
		Jp2.add (Fanhui);
		Add (JP2, Borderlayout.south);
		Add (JP);
		Add (New JLabel (""), borderlayout.west);

		Add (New JLabel (""), Borderlayout.east); SetVisible (TRUE);
				Zhuce.addactionlistener (new ActionListener () {//Check that the registration information entered meets the requirements public void actionperformed (ActionEvent e) {
					if (Usernamefield.gettext (). Trim (). Length () < 6) {Joptionpane.showmessagedialog (zhuce.this, "Insufficient user name");
				Return
					else if (Passwordfield.gettext (). Trim (). Length () < 6) {Joptionpane.showmessagedialog (zhuce.this, "Not Enough password length");
				Return
					else if (!passwordfield.gettext (). Trim (). Equals (Repasswordfield.gettext (). Trim ())) {
					Joptionpane.showmessagedialog (zhuce.this, "Two input passwords are different");
				Return ///Send registration information//Registration information 1 Login Information 2 Chat 3 String message = 1 + "" + usernamefield.gettext (). Trim () + "" + Password
				Field.gettext (). Trim ();
				Messageio io = new Messageio (); Io.

				SendMessage (message); Receive registration results//Success Y failed n String jieshou = io.
				Recerivemessag ();
					if (jieshou.equals ("Y")) {Joptionpane.showmessagedialog (Zhuce.this, "registered successfully");
					Zhuce.this.dispose ();

				New DENGLUJM (); } ELSE if (Jieshou.equals ("n")) {Joptionpane.showmessagedialog (Zhuce.this, "username already exists");
				Return
		
		}
			}

		}); Fanhui.addactionlistener (new ActionListener () {@Override public void actionperformed (ActionEvent arg0) {en
				Uce.this.dispose ();
				
			New DENGLUJM ();
	}
		});
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.