How to manage GridLayout settings accordingly on JAVA?

I have setLayout (new GridLayout (5,5,3,3));

5 rows and 5 columns. In the first line I want one big line. You know, as in excel, where you will merge cells. So I just want to combine 5 columns in the first row only. I put JLabel on the first line, and it is very annoying that I need to have several JLabels for each grid cell and make sure the spacing works well.

Is there any way to do this on GridLayout? Or am I stuck in 5 rows and 5 columns strictly?

+3
source share
1 answer

GridBagLayoutcan do it. In addition, you can use nested layouts: add the first line to NORTH BorderLayoutand leave GridLayoutin CENTER. See Also Visual Guide for Layout Managers .

Addendum: MiGLayout is also worth a look in this context. The Web Start demo is particularly attractive, and the Merge and Separate Cells section of the manual may be useful .

+5
source

Source: https://habr.com/ru/post/1774614/


All Articles