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 ();
}
});
}
}