views:

48

answers:

4

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.

+1  A: 

Maybe a GridBagLayout is what you need.

ymene
I want the size of each component to be based on it's inner-components. You can't do that with a `GridBagLayout` can you?
Gnarly
Indeed, you can't. Got u wrong it seems. Maybe a screenshot could help to see what u really try to achieve, but using a groupLayout can perfectly do what u want I guess, nevertheless its not that easy to arrange components in a GroupLayout. With GridBagLayout the design of a component only effects the column and the row, where the component is placed.But it seems that u dont need something like a grid at all.
ymene
+3  A: 

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

Michael Borgwardt
I edited my OP.
Gnarly
@Gnarly: read the section about Component Size and Resizability in the document I linked to.
Michael Borgwardt
+3  A: 

No, all cells are equal by design.

Konrad Garus
+2  A: 

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.

Jason Day