Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
GridLayout Posted by vindesh on 31 Mar 2006 at 12:47 AM
How to use GridBageLayout in java

Report
Re: GridLayout Posted by zibadian on 31 Mar 2006 at 1:40 AM
: How to use GridBageLayout in java
:
:
Call the Container.setLayout() of the container object, whose layout you want to change, and specify a GridLayout object. The GridLayout object can be made on the fly with new:
  MyApplet.setLayout(new GridLayout(3, 4));

, or be stored in a variable. The parameters define the number of grid cells in x, y directions.
Each component, which is added to the Container, is added row by row from top-left to bottom-right. Example:
  this.setLayout(new GridLayout(2, 2));
  this.add(Label1);
  this.add(Label2);
  this.add(Label3);
  this.add(Label4);

produces a layout of:
  Label1         Label2

  Label3         Label4

Additional settings like the spacing of the grid cells can be specified. See javadoc for more info on the variables/methods in GridLayout.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.