GridLayout - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!



vindeshvindesh Posts: 1Member
How to use GridBageLayout in java


  • zibadianzibadian Posts: 6,349Member
    : 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));
    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.
Sign In or Register to comment.