• 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

Sizing up all my components!

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have dozens and dozens of JLabels and JTextFields and JTable. And now I want to every thing have a bigger font. How do I go about doing this? I was wondering how to change color on a JLabel once, and someone proposed to use HTML tags around my string, which worked fine. But I really need a more efficient way this time or this is going to take forever!
Let me know!
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, for the JLabel anyhow, maybe extend it to create a JLabel that has the attributes you want and make all your JLabels one of those objects. (e.g., MyBlueTahomaLabel, MyBlueTahomaCheckBox, etc).
or make a "label adder" helper method that (if called) will add the label in the desired font and color (e.g., addBlueTahomaLabel(String text, ...)). this works best if your layout is fairly straightforward and each label can be added given the passed in parameters. like you might pass in x/y coordinates or gridbagconstraints. along those lines, create "adder" methods for other types of components.
just to screw around. there's probably a more elegant way of getting what you want done...
if you needed to put html tags around all the labels for some reason, you could override whatever method it is that renders the text and always nest the text value inside the html tags so that the same code does the same work in the same place for all the same type of component.
or you could write a little engine that iterates over all the visible components in your container(s) and sets the font and color (if setters are available).
just some ideas to pick from. probably plenty of others too..
 
reply
    Bookmark Topic Watch Topic
  • New Topic