Search code examples
javaswinglayout-managergrid-layout

How do i force GridLayout to always have 7 columns


(This is on Java Swing)

I created a gridLayout(6,7), however it looks like it prefers to comply the Vertical requirement with higher priority than the horizontal. I mean, it will always have 6 rows, disregarding the 7 columns i want it to have. I want it so it always has 7 columns, i dont really care about the rows. (Its a calendar)

How can i accomplish this?


Solution

  • Set the number of rows to 0 for the layout manager

    panel.setLayout(new GridLayout(0, 7));