In my swing application, I have different types of text I'd like to display. For example, I want to display a heading text before a list of choices, something like:
Select choice: a b
I want the "Select Choice" label to use the "Heading" font (something I define), and the choices to use the "Choice" font. This pattern will occur multiple places in my application, so ideally I'd like to centralize where the fonts are set.
My current approach is to use a factory to create the different label types:
LabelFactory.createHeadingLabel("LabelText");
LabelFactory.createChoiceLabel("ChoiceText");
The factory reads in a properties file specifying the fonts and I customize the labels when they are created in the factory. I know that using a factory like this works, but I'm not sure if there is a standard Swing convention for doing something like this. Any input would be appreciated.