Tuesday, May 31, 2011

I program in java and i wanted to know how to change font...?

ok so i program java and i want to know how to change font and/or increase font size but in applications not apelets. i hope u get what i mean.I program in java and i wanted to know how to change font...?
If you just want to change the font size on a few components, then create a java.awt.Font object specifying the font family, special attributes (italics, bold, etc.), and the desired point size. Then on each component desired, invoke setFont();



example:

Font font = new Font(';Serif';, Font.BOLD, 32);

JButton ok = new JButton(';OK';);

ok.setFont(font);



Now, if you want to apply the font globally, or to all the components, but say, maybe not the JFrame titlebar, then look at articles on creating themes for the Metal (Java) Look and Feel, most easily done by subclassing DefaultMetalTheme or OceanTheme.

No comments:

Post a Comment