Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why is Swing text always bold?

 
Derek Boring
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not. Can you post a minimal example (i.e., as little code as possible) of a complete Swing program that exhibits this?
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can change the font:
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Ilja said, some l&fs use bold by default. With my code you can explicitly disable it.
 
Derek Boring
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

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


[ March 18, 2008: Message edited by: Derek Boring ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic