Setting the Stretchyness of Columns and Rows in a GridBagLayout Using Component Weights

See Setting the Stretchyness of Rows and Columns in a GridBagLayout Using Layout Weights for an explanation of stretchyness and weights. This example demonstrates how to set the weight of a row or column by assigning the weight on a component.

See Creating a GridBagLayout for an example on how to use a gridbag layout with gridbag constraints.

GridBagLayout gbl = new GridBagLayout(); container.setLayout(gbl); // Place a component at (0,1) with a column weight 1 and // a row weight of 2 GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 1; gbc.weighty = 2; gbl.setConstraints(component, gbc); container.add(component);

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.