The GridLayout of Swing

Source: Internet
Author: User

Package Gui1;import Java.awt.flowlayout;import java.awt.gridlayout;import javax.swing.jbutton;import Javax.swing.JFrame; Public classGRIDLAYOUT1 extends jframe{JButton [] a={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};  Public Static voidMain (string[] args) {//TODO auto-generated Method StubGRIDLAYOUT1 g1=Newgridlayout1 (); } Publicgridlayout1 () {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 (NewGridLayout (3,3, the, the));//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 ("Grid Layout GridLayout");  This. SetSize ( -, the);  This. setlocation ( -, the);  This. setresizable (true);  This. Setdefaultcloseoperation (Jframe.exit_on_close);  This. setvisible (true); }}

The GridLayout of Swing

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.