> I'm building an application whose Swing components should change in
> response to application generated events e.g. someone clicks change
[quoted text clipped - 8 lines]
>
> many thanks in advance.
Have you looked into creating a custom look and feel using properties
you've defined?
IE
public class MyLookAndFeel extends MetalLookAndFeel
{
protected void initComponentDefaults(UIDefaults table)
{
super.initComponentDefaults();
Object [] uiDefaults =
{
"my.big.font", new Font ("Arial, Font.PLAIN, 20))
//etc
}
table.putDefaults(uiDefaults);
}
}
Then when the user clicks to change font:
UIManager.setLookAndFeel (new MyLookAndFeel());
The trick is that all of your JComponents then need to override
updateUI(). In updateUI() you can load the fonts using something
like:
myJLabel.setFont(UIManager.getFont("my.big.font"));
Btw, for anyone reading this, I would like to know if this approach is
considered a big no-no, or if it's pretty reasonable. Obviously it's
a bit of a pain in the butt needing to override updateUI() all over
the place.

Signature
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
JavaEnquirer - 27 Jan 2006 17:58 GMT
Sounds like an interesting idea, thanks! I'm also interested in other
people's opinions on your suggestion. However, I will also need to
change the text on JLabels, JButtons etc if the user decides to change
the language. Another requirement is for dynamic language changing.
Monique Y. Mudama - 27 Jan 2006 19:08 GMT
> Sounds like an interesting idea, thanks! I'm also interested in
> other people's opinions on your suggestion. However, I will also
> need to change the text on JLabels, JButtons etc if the user decides
> to change the language. Another requirement is for dynamic language
> changing.
You can actually put any arbitrary Object in a LnF, so in theory you
could also store Strings. But I don't think you would want a LnF
object for each permutation of language/font size/etc. I can think of
a way to do this by keeping track of a static language flag and using
a different LnF object for each language, but it feels like the wrong
approach.
By the way, I do know that the approach to changing "skins" works -- I
just don't know if it's considered an ugly hack.

Signature
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html