• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Swing- FlowLayout inside BorderLayout

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic