aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Why is Swing text always bold? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Why is Swing text always bold?" Watch "Why is Swing text always bold?" New topic
Author

Why is Swing text always bold?

Derek Boring
Ranch Hand

Joined: Aug 15, 2006
Posts: 63
Has anyone ever noticed how text in every swing component, excluding text editing components, is always bold?

What is the reason for this and how can I turn it off?

I already tried setting the text with a </B> tag before it:

"<HTML></B>The Text</HTML>"

But it's still bold.


Life is 10% what happens and 90% how you react to it.
Attitude is everything.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
It's not. Can you post a minimal example (i.e., as little code as possible) of a complete Swing program that exhibits this?


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

You can change the font:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Ulf Dittmer:
It's not. Can you post a minimal example (i.e., as little code as possible) of a complete Swing program that exhibits this?


I can:

JOptionPane.showMessageDialog(null, "<html>normal <b>bold</b></html>");

I'd guess that this is dependent on the look&feel you use, though.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
JOptionPane.showMessageDialog(null, "<html>normal <b>bold</b></html>");

But that explicitly specifies to display bold. I understood the original post to say that it didn't. That's what the example shows, anyways.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

As Ilja said, some l&fs use bold by default. With my code you can explicitly disable it.
Derek Boring
Ranch Hand

Joined: Aug 15, 2006
Posts: 63
Thanks.

I found this code in a tutorial from Sun's website today:


[ March 18, 2008: Message edited by: Derek Boring ]
 
 
subject: Why is Swing text always bold?