Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to prevent wrapping in conjunction with FlowLayout?  RSS feed

 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

One of my dialogs is composed of several panes. One of these panes in the bottom of the JDialog holds all buttons, all of which are aligned horizontally in a row setting the layout of the containing JPanel to FLowLayout.

When decreasing the size of the dialog, at a certain point, that is the horizontal space of the pane isn't enough anymore to display all buttons in a single row, wrapping comes into play.
It looks really bad!
How can I avoid this wrapping behavior in FlowLayout? Do I have to use another LayoutManager like BoxLayout?

Thanks,
Andy
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I have to use another LayoutManager like BoxLayout?


Yes.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or put the panel in a scroll pane.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another alternative would be to to limit the minimum size ot the containing window.
But how can I figure out the total horizontal size of the buttons row? This value should be the minimum width of the window.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getPreferredSize().width

Don't forget about the FlowLayout's HGap.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!