The gridwidth
and gridheight
fields
specify the number of cells in a row (gridwidth
) or
column (gridheight
) in the Component
's
display area. The mnemonic constant
GridBagConstraints.REMAINDER
specifies that the
Component
should use all remaining cells in its row (for
gridwidth
) or column (for gridheight
).
The mnemonic constant GridBagConstraints.RELATIVE
specifies that the Component
should fill all but the
last cell in its row (gridwidth
) or column
(gridheight
).
The calculator's display is four cells wide and one cell high so it's set like this
displayConstraints.gridwidth = 4;
displayConstraints.gridheight = 1;
The equals key is two cells high and one wide so it's set like this
equalsConstraints.gridwidth = 1;
equalsConstraints.gridheight = 2;