You can drag a component in a GridBagLayout to make it
span multiple cells. You can also specify the width and height of
a component using Properties view or the Customize Layout window.
About this task
By default, when you drop a component into a GridBagLayout,
the visual editor sets the x and y values to assign it to a cell.
However, two additional constraints available for a component are gridheight
and gridwidth, which are properties on the GridBagConstraints object
that is instantiated for each component.
- The gridheight constraint is an integer that indicates the number
of rows that the component spans.
- The gridwidth constraint is an integer that indicates the number
of columns that the component spans.
To span a component across multiple cells in a GridBagLayout: