• 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

how to size a label?

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello all,
i am wondering if there is a way to create a label in the size you want.
e.g JLabel label0 = new JLabel("Year ", JLabel.RIGHT);
how to define its size you want???
Mindy
Thanks!
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Labels have a "preferred size" that the LayoutManager tries to respect. As a rule that is "just big enough to hold the String". The size of the string depends on the Font that you are using and the String itself of course. You can try to pad the label with spaces to add width.
The idea is that you really don't WANT to specify the size, because when it looks good on your machine it will look bad on the next O, or when the user messes with the size of the screen etc.
 
Mindy Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Cindy!
reply
    Bookmark Topic Watch Topic
  • New Topic