The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Need help with very specific panel layout

Hi there.

For the last couple of days I tried to lay out a panel in a specific way but no layoutManager I picked was able to get it quite right.
So I am asking here whether someone can suggest to me what kind of layout manager(s) to use for this.

It looks like the BorderLayout is the perfect choice, but the problem is, when I use the BorderLayout the top panel will never grow in height as rows are needed.
The top will always have a fixed height of only a single row.

I have also tried other layout managers most were not able to fix the top panels height, others had problems with the size restrictions on the toolbar or came with other problems.

Re: Need help with very specific panel layout

Interesting. Upon doing some more research, it turns out that the problem is with your FlowLayout. BorderLayout respect's the TOP component's preferred size, however, FlowLayout doesn't set its preferred size to make sure every row is visible. FlowLayout's preferred size assumes only one row of components will be added.

Re: Need help with very specific panel layout

This is even more intersting since the FlowLayout claims that it would add additional Rows as needed.
I will see if I can get it to work and update the thread.

--- Update ---

I cant seem to find a LayoutManager that does what the FlowLayout promises. (at least not without a lot of work)
The problem is that I need to be able to dynamically add / remove Components to / from the top panel and have it resized automatically.

Can you give me any suggestion what Layout might do this job without having to write too much code around it?
Alternatively I guess I would create my own Layout which extends the FlowLayout and "fixes" this "feature".