| 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: 32649
|
|
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: 1788
|
|
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.
|
 |
 |
|
|
subject: Swing- FlowLayout inside BorderLayout
|
|
|