This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel size  RSS feed

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I make a JLabel 40 characters (for example) wide? If I instantiate it with a huge long empty string it still scrunches up to a relatively small size. When I setText() into it, it sticks it so far over to the right of the JLabel, I usually can't see it.
Thanks!
Paul
 
Jeff Wisard
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would play around with alternate layout managers if I were you. Although it is the most complex, GridBagLayout is the most powerful layout manager and you could definetely work this out using one.
You could probably do this also with BorderLayout, GridLayout, or even a FlowLayout. You may have to use multiple layouts to get the desired effect. Just play with it!
Hope this helps!
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try setMinimumSize() it won't let it go less than that size. setPreferredSize() might work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!