Java Development GUI Program general steps:

Source: Internet
Author: User

Development GUI Program General step: 1, import java.awt.* of introduction package; Import javax.swing.*; 2, inherit JFrame public class Demo3 extends JFrame {} 3, define required components//3. Define Components JButton jb1,jb2,jb3,jb4,jb5;   int size=9;  JButton Jbs[]=new Jbutton[size]; First allocate initial space 4, create component//4. Create Component Jb1=new JButton ("Middle");   Create a component for (int i=0;i<size;i++) {jbs[i]=new JButton (string.valueof (i)); } 5, set layout Manager//Set layout manager, default is the Boundary Layout manager this.setlayout (new FlowLayout (Flowlayout.left));//Flow Layout This.add (JB1,              Borderlayout.center);  Border Layout this.setlayout (new GridLayout (3,3,10,10));  Grid layout this.setlayout (null);   Cancel Layout Manager 6, Add components//Add Components This.add (JB1); This.add (JB2);  7. Set form Properties//Set form Properties This.settitle ("Flow layout case");       Set the form title This.setsize (300, 200);   Set the form size this.setlocation (200, 400);   Set initial position this.setdefaultcloseoperation (jframe.exit_on_close);   Close the virtual machine when the form is closed//prevents the user from changing the form size this.setresizable (false); 7. Display Form this.setvisible (true);  8. Display form create component with array://define component int size=9;  JButton Jbs[]=new Jbutton[size]; Array to first allocate the initial emptyBetween//Create component for (int i=0;i<size;i++) {jbs[i]=new JButton (string.valueof (i));   }//Add component for (int i=0;i<size;i++) {this.add (jbs[i]);

Java Development GUI Program general steps:

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.