dcsimg
Font Always Bold Style
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Stephen_McConnell
Posted On:   Friday, September 5, 2003 12:45 PM

I'm writing a Swing Application and seem to be having a problem with the Fonts. On my first Label, the font appears like I want it... Font.PLAIN, size = 12. However, after calling and using a JComboBox, all fonts from then on appear as a FONT.BOLD, size = 12. Even when I explicitly set it on my JLabel using... Font lf = UIManager.getFont("Label.font"); Font labelFont = new Font(lf.getFontName(), Font.PLAIN, 12); JLabel test = new JLable("Test me"); test.setFont(labelFont); it continues to be bold. If I change it to Font.ITALIC, it changes to Italic, but continues to be bold, also. I have   More>>

I'm writing a Swing Application and seem to be having a problem with the Fonts.


On my first Label, the font appears like I want it... Font.PLAIN, size = 12.


However, after calling and using a JComboBox, all fonts from then on appear as a FONT.BOLD, size = 12.


Even when I explicitly set it on my JLabel using...

			
Font lf = UIManager.getFont("Label.font");
Font labelFont = new Font(lf.getFontName(),
Font.PLAIN,
12);
JLabel test = new JLable("Test me");
test.setFont(labelFont);


it continues to be bold. If I change it to Font.ITALIC, it changes to Italic, but continues to be bold, also.


I have done nothing to change the fonts elsewhere. I am using JDK 1.4.2 on Windows XP (unfortunately).


Is this a bug in the JDK or am I missing something?


Stephen McConnell

   <<Less

Re: Font Always Bold Style

Posted By:   Bahman_Barzideh  
Posted On:   Friday, September 5, 2003 03:34 PM

There may be a bug in the JDK that causes this (I run 1.4.1 on a Mac; if you like post a small standalone example & I will be happy to test it
on my box). In the meantime see if the following code helps any:

try {
Font font = (java.awt.Font) UIManager.get ("Label.font");
UIManager.put ("Label.font", new Font (font.getName (), Font.PLAIN, 12));
}
catch (Exception ex) {
}
About | Sitemap | Contact