GridLayout - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

GridLayout

vindeshvindesh Posts: 1Member
How to use GridBageLayout in java

Comments

  • 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:
    [code]
    MyApplet.setLayout(new GridLayout(3, 4));
    [/code]
    , 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:
    [code]
    this.setLayout(new GridLayout(2, 2));
    this.add(Label1);
    this.add(Label2);
    this.add(Label3);
    this.add(Label4);
    [/code]
    produces a layout of:
    [code]
    Label1 Label2

    Label3 Label4
    [/code]
    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.