• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing- FlowLayout inside BorderLayout

 
David Kowalski
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
I'm new to swing I have been reading about the flow and border and I'm quite sure I know how they work.
But well I can't figure out one thing, when I put FlowLayout with let's say 5 buttons inside border layout as the north panel and what I'm trying to do is when I resize the window I want the buttons to not dissappear but instead show in new line, it is working with just FlowLayout but inside border when I have something under the north panel the buttons are just hidden.
I have been trying to do this using PreferredLayoutSize.
The thing I would like to know, where do I have to put the dimension from PreferredLayoutSize to make it work?

Thanks for answers.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49864
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
Why do you want flow layout at all? Inside border layout the components will shrink as the whole display is shrunk. A flow layout needs to retain enough area to display all its cotained components, otherwise they fall off the end and disappear.
Try a 5×1 grid layout instead, or a horizontal box layout.
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately the FlowLayout doesn't automatically increase the preferred height of the component once the components wrap to a new row.

You can use Wrap Layout which extends FlowLayout to provide this functionality.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic