Example usage for java.awt GridBagLayout getLayoutWeights

List of usage examples for java.awt GridBagLayout getLayoutWeights

Introduction

In this page you can find the example usage for java.awt GridBagLayout getLayoutWeights.

Prototype

public double[][] getLayoutWeights() 

Source Link

Document

Determines the weights of the layout grid's columns and rows.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JFrame frame = new JFrame();
    GridBagLayout gbl = new GridBagLayout();

    frame.setLayout(gbl);/*from  w  w w.j a  v a2s.c  om*/
    frame.add(new JButton("1"));
    frame.add(new JButton("2"));

    gbl.layoutContainer(frame);

    double[][] weights = gbl.getLayoutWeights();
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < weights[i].length; j++) {
            weights[i][j] = 1;
        }
    }
    gbl.columnWeights = weights[0];
    gbl.rowWeights = weights[1];

    frame.pack();
    frame.setVisible(true);
}