Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to fix the size if button in a panel  RSS feed

 
Syed Basha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got series of button in BoxLayout-Y axix.
But the buttons are all different size. I need them tobe in same size.
Button.setPreferredSize() is discouraged. Any solution ?
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Syed
Not sure why you would not want to use that method. From the API:

Sets the preferred size of this component. If preferredSize is null, the UI will be asked for the preferred size.

So all you are doing is bypassing the UI code to get preffered size.
You could space fill your titles but the spaces are very narrow and that seem like a worse solution.
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is Button.setPreferredSize() discouraged ?
This is how you would normally do it, maybe also using setMaximiumSizew and setMinimumSize depending on your requirements.
D.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!