Day 5:update Qqreg & Qqserver.java

Source: Internet
Author: User
Tags gettext

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

Related Article

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.