The FlowLayout of Swing

Source: Internet
Author: User

import Java.awt.flowlayout;import javax.swing.jbutton;import javax.swing.JFrame;//1. Inheriting the JFrame class//2. Defining components at the top//3. Creating a component in the construction method//4. Adding components in the construction method//5. Setting Form Properties//6. Display the form//7. Creating an object in the main function Public classFLOWLAYOUT1 extends jframe{JButton [] a={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};  Public Static voidMain (string[] args) {//TODO auto-generated Method StubFLOWLAYOUT1 f1=Newflowlayout1 (); }     Publicflowlayout1 () {a[0]=NewJButton ("melon Seeds"); a[1]=NewJButton ("Plum"); a[2]=NewJButton ("Watermelon"); a[3]=NewJButton ("Strawberry"); a[4]=NewJButton ("Banana"); a[5]=NewJButton ("Apple"); a[6]=NewJButton ("Chestnut"); a[7]=NewJButton ("Cucumber"); //a[8]=new JButton ("Grape");                 This. setlayout (NewFlowLayout (flowlayout.leading));//The default is the boundary layout, if you want to change to another layout, plus                 This. Add (a[0]);  This. Add (a[1]);  This. Add (a[2]);  This. Add (a[3]);  This. Add (a[4]);  This. Add (a[5]);  This. Add (a[6]);  This. Add (a[7]);  This. Settitle ("Flow Layout FlowLayout");  This. SetSize ( -, the);  This. setlocation ( -, the);  This. setresizable (true);  This. Setdefaultcloseoperation (Jframe.exit_on_close);  This. setvisible (true); }}

Swing's FlowLayout

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.