user2144555
user2144555

Reputation: 1313

Resizing panels in a GridLayout

I want this:

enter image description here

My frame is a GridLayout (3,2), and all I can have is this:

enter image description here

I put the button in a panel, I think it's easier. But how can I change the size of the grid?

Upvotes: 2

Views: 740

Answers (2)

Gilbert Le Blanc
Gilbert Le Blanc

Reputation: 51445

As you've seen, GridLayout makes all of the cells in a grid the same size.

Your layout consists of two JPanels inside of a main JPanel.

The main JPanel will have a BoxLayout with a Y axis.

The panel JPanel will have a GridBagLayout.

The button JPanel will have a FlowLayout.

Upvotes: 0

StanislavL
StanislavL

Reputation: 57381

Choose another LayoutManager e.g. GridBagLayout

Upvotes: 3

Related Questions