Java interface Design 3///Dear God, please see what I understand, right? How to understand and how to train

Source: Internet
Author: User

Importjava.awt.*; Public classbuttondemo{ Public StaticJPanel Createmainpanel () {JPanel Mainpanel=NewJPanel ();//Mainpanel: Intermediate containerJPanel panel1=NewJPanel ();//PanelPanel1.add (NewJLabel ("User name")); JTextField Text1=NewJTextField ();//edit a single line of textText1.setcolumns (10);//Queue ModeText2.sethorizontalalignment (Jtextfield.center);//sets the orientation of the component's content horizontally aligned, you set the center alignmentPanel1.add (Text1); Panel1.setvisible (true);               Mainpanel.add (PANEL1); JPanel Panel2=NewJPanel (); Panel2.add (NewJLabel ("User name password")); JTextField Text2=NewJTextField (); Text2.setcolumns (10);               Text2.sethorizontalalignment (Jtextfield.center);               Panel2.add (TEXT2); Panel2.setvisible (true); Mainpanel (Panel2)//Add a panel to an intermediate containerJPanel panel3=NewJPanel (); Panel3.add (NewJLabel ("Gender")); Jradiobutton Radio1=NewJradiobutton ("Male"); Jradiobutton Radio2=NewJradiobutton ("female"); Radio1.setselected (true);//Specifies whether to selectButtongroup Btngroup =NewButtongroup ();//Create a button groupBtngroup.add (RADIO1);               Btngroup.add (Radio2); Panel3.setvisible (true);               Mainpanel.add (PANEL3); JPanel Panel4=Newjpanel (); Panel4.setlayout (NewGridLayout (2,3)); Panel4.add (NewJlanel ("Hobby")); Jcheckbox checkbox=NewJcheckbox ("Art"); Checkbox.setselected (true);               Panel4.add (checkbox); Panel4.add (NewJchekbox ("Basketball")); Panel4.add (NewJcheckbox ("Volleyball")); Panel4.setvisible (true);               Mainpanel.add (PANEL4); JPanel Panel5=NewJPanel (); Panel5.add (NewJLabel ("register")); Panel5.add (NewJlanel ("Cancel")); Panel5.setvisible (true);               Mainpanel (PANEL5); returnMainpanel;//return to intermediate container          }              Public Static voidMain (String args[]) {JFrame frm=NewJFrame ("button instance"); Frm.setsize (300,300); Container Con=frm.getcontentpanel ();//get a container panel to hold componentsCon.add (Createmainpanel ());//This does not understand
                 frm.setvisible (true);}}











Java interface Design 3///Dear God, please see what I understand, right? How to understand and how to train

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.