aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Swing- FlowLayout inside BorderLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing- FlowLayout inside BorderLayout" Watch "Swing- FlowLayout inside BorderLayout" New topic
Author

Swing- FlowLayout inside BorderLayout

David Kowalski
Greenhorn

Joined: Mar 06, 2013
Posts: 2
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

Joined: Oct 13, 2005
Posts: 39393
    
  28
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

Joined: Jun 13, 2009
Posts: 2200
    
    7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing- FlowLayout inside BorderLayout