Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting columnWidth and rowHeight in GridBagLayout

How to set columnWidth and rowHeight in GridBagLayout? Is it gridWidth and gridHeight?

enter image description here

How this column Widths can be specified dyanmically?

like image 998
FirmView Avatar asked Jul 19 '26 12:07

FirmView


2 Answers

According to the JavaDocs

gridheight

Specifies the number of cells in a column for the component's display area. Use REMAINDER to specify that the component's display area will be from gridy to the last cell in the column. Use RELATIVE to specify that the component's display area will be from gridy to the next to the last one in its column.

gridheight should be a non-negative value and the default value is 1.

gridwidth

Specifies the number of cells in a row for the component's display area. Use REMAINDER to specify that the component's display area will be from gridx to the last cell in the row. Use RELATIVE to specify that the component's display area will be from gridx to the next to the last one in its row.

gridwidth should be non-negative and the default value is 1.

So, if you want to specify the number of rows or columns a component will span, then, yes

like image 160
MadProgrammer Avatar answered Jul 21 '26 04:07

MadProgrammer


You cannot specify the width and height of a cell in GridBagLayout; if that is what you are looking to do. Th layout manager calculates row height based on all components in the row.

You can check this Oracle tutorial on GridBagLayout

Added Based on the screen shot you added seems you are using some tool like JFormDesigner. It is a customised layout, column width and column height does not come in standard GridBagLayout.

like image 28
basiljames Avatar answered Jul 21 '26 04:07

basiljames



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!