• 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

in flow lay out how can i force to add component on next line?

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Ranchar i would like to know one thing that as we know that flow lay out arrange component from left to right and work as word wrapping feature of ms word well but i want by flow lay out that after adding two component next component should be added on the next line how can i accomplise that ?

Regard

Arun
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't.

ok, nothing is impossible and there are some creative ways (read: "hacks") I can think of that might force FlowLayout to do something like this. But the easiest way to achieve the effect you want is to have two nested Containers within your Container. It would look something like this:

 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you can set the preferredSize to your FlowLayout panel. When the next is added to the panel it's added on a new row.
[ January 08, 2007: Message edited by: Mathias Nilsson ]
 
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep

 
Greenhorn
Posts: 5
Spring AngularJS Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adding the help for Vertical layout for BoxLayout.
Following line of code will help setting vertical layout of components in the Panel.


Code Sourced from Stackoverflow
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i want by flow lay out that after adding two component next component should be added on the next line



That is not the way FlowLayout is designed to work. You need to use a different layout manager or combination of layout managers:

1. You could use a GridLayout. For example. GridLayout layout = new GridLayout(0, 2); This will wrap components to a new line after 2 columns have been filled. However, all components will be the same size.

2. You could use a GridBagLayout. In this case you need to specify the row/column of each component you add so you manually create your grid.

3. You could use a vertical BoxLayout. Then you create child panels to add to the layout. Each child panel can contain a panel using a FlowLayout with two components.

Read the Swing tutorial on Layout Managers for more information and examples.

You can also have the FlowLayout dynamically flow components to a new line as the components fill the current line. So as the frame is resized the components will wrap as required. See: Wrap Layout.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic