Importjava.awt.*;Importjavax.swing.*;Importjava.net.*;ImportJava.io.*;Importjava.awt.event.*; Public classQqregextendsJFrameImplementsactionlistener{ Public Static voidMain (string[] args) {Qqreg W=NewQqreg (); W.setvisible (true); } JTextField Txtuser=NewJTextField (); JPasswordField Txtpass=NewJPasswordField (); JPasswordField Txtpassre=NewJPasswordField (); Qqreg () {//set up basic information for a form This. SetSize (660, 380); This. Setlocationrelativeto (NULL); This. Settitle ("Talking.GHOUL.Reg"); This. setresizable (false); This. Seticonimage ( This. Gettoolkit (). GetImage ("D:/LAB_2/PSB (one). jpg")); //New Components & Setup ComponentsJLabel Labtitle =NewJLabel ("Sign Up"); Labtitle.setfont (NewFont ("", 0, 36)); JLabel Labuser=NewJLabel ("Username"); Labuser.setfont (NewFont ("", 0, 30)); JLabel Labpass=NewJLabel ("Password"); Labpass.setfont (NewFont ("", 0, 30)); JLabel Labpassre=NewJLabel ("Confirm Password"); Labpassre.setfont (NewFont ("", 0, 30)); //------Update-----------------------//JComboBox cmbusername = new JComboBox (); //Cmbusername.setfont (New Font ("", 0, 30)); //Cmbusername.additem ("かねきけん"); //Cmbusername.additem ("Kaneki Ken"); //Cmbusername.additem ("Jinmu");Txtuser.setfont (NewFont ("", 0, 30)); Txtpass.setfont (NewFont ("", 0, 25)); Txtpassre.setfont (NewFont ("", 0, 25)); JButton Btnreg=NewJButton ("CONFIRM"); Btnreg.setfont (NewFont ("", 0, 30)); //registering for event monitoringBtnreg.addactionlistener ( This); //layout The main panelJPanel Panuser =NewJPanel (); Panuser.setlayout (NewGridLayout (3, 3)); Panuser.add (Labuser); Panuser.add (Txtuser); Panuser.add (Labpass); Panuser.add (Txtpass); Panuser.add (LABPASSRE); Panuser.add (TXTPASSRE); //Layout button PanelJPanel Panbutton =NewJPanel (); Panbutton.setlayout (NewFlowLayout ()); Panbutton.add (Btnreg); //Layout Form This. setlayout (NewBorderLayout ()); This. Add (Labtitle, Borderlayout.north); This. Add (Panuser, borderlayout.center); This. Add (Panbutton, Borderlayout.south); } @Override Public voidactionperformed (ActionEvent arg0) {//System.out.println (arg0); if(Arg0.getactioncommand (). Equals ("CONFIRM")){ Try{String User=Txtuser.gettext (); String Pass=Txtpass.gettext (); Socket s=NewSocket ("127.0.0.1", 8000); OutputStream OS=S.getoutputstream (); OutputStreamWriter OSW=Newoutputstreamwriter (OS); PrintWriter PW=NewPrintWriter (OSW,true); Pw.println (User+"%"+pass); }Catch(Exception e) {} }}}
ImportJava.io.*;Importjava.net.*; Public classqqserver{ Public Static voidMain (string[] args) {Try{ //listening on port 8000ServerSocket SS =NewServerSocket (8000); System.out.println ("Waiting for client messages ..."); Socket s=ss.accept (); //Accept user name and passwordInputStream is =S.getinputstream (); InputStreamReader ISR=NewInputStreamReader (IS); BufferedReader BR=NewBufferedReader (ISR); String UANDP=Br.readline (); //Inspection PointSystem.out.println (UANDP); }Catch(Exception e) {} }}
Day 5:update Qqreg & Qqserver.java