This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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!
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..