user238033
user238033

Reputation:

Is it possible to make GridLayout's components not equal in size?

GirdLayout makes a bunch of components equal in size. That means that the biggest sized component will define the size for all components. Is it possible to make each component's size based on their inner-components instead?

EDIT: If it's not possible, how could I get the same effect as a GridLayout but with each component's size based on their inner-components.

Upvotes: 2

Views: 6062

Answers (4)

Michael Borgwardt
Michael Borgwardt

Reputation: 346465

No, you'll have to use a different layout manager for that. GroupLayout would be an option.

Upvotes: 5

Jason Day
Jason Day

Reputation: 8839

It's not possible, but you can use nested components in each cell. For example, if you don't want a JButton to expand to the size of a cell, add it to a Jpanel, then add the JPanel to the cell.

Upvotes: 2

Konrad Garus
Konrad Garus

Reputation: 54035

No, all cells are equal by design.

Upvotes: 4

crusam
crusam

Reputation: 6178

Maybe a GridBagLayout is what you need.

Upvotes: 1

Related Questions