• Post Reply Bookmark Topic Watch Topic
  • New Topic

XAlignment with GridLayout  RSS feed

 
Tom Josephits
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a list of buttons I want displayed vertically down the center. I tried BoxLayout with a "setAlignmentX(Component.CENTER_ALIGNMENT)" on the buttons but then they all end up crunched together and it doesn't look very good. SO I switched to GridLayout witch spaced them very nicely, but now it's ignoring the X Alignment. How can I get this to work?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you start from the API documentation for BoxLayout, you'll find not too far from the top a link to the tutorial "How to Use BoxLayout". In this tutorial it says

The tutorial wrote:Each component controlled by a box layout butts up against its neighboring components. If you want to have space between components, you can either add an empty border to one or both components, or insert invisible components to provide the space. You can create invisible components with the help of the Box class.


Carry on reading from that point for tips on how to solve your problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!