This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Changing the color of a String... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changing the color of a String..." Watch "Changing the color of a String..." New topic
Author

Changing the color of a String...

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
I have a string that outputs the message "Your order number is 999999 and your code is TEST" on a JOptionPane. I want to change the font and the color of the order number, and the code. How on earth can I do something like this??
Thanks for any help!
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Labels support HTML tags, so you could use a FONT tag...



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Thanks for the reply! However, I may be doing something wrong. When I tried to put HTML tags in my JLabel, It read displayed it with the HTML tags as text. Am I missing something?
Thanks again!
Zhao Fu Qiang
Greenhorn

Joined: May 29, 2002
Posts: 10
Nathan Pruett is right! Maybe your swing version is low!


Extreme Component, Inc.
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
I am using j2sdk1.4. This should work shouldn't it?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Jennifer,
Do you have this problem when you compile and run Nathan's example?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I'm running under 1.4 also, and I see the HTML tags working...
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Thanks for the help guys! I ran Nathan's code and it worked. I had previously deleted the code I wrote last time when I tried this on my app, so I redid it. Now it works! Maybe I left something out of the HTML that needed to be in there. I'm not sure what it was. But thanks again for all of your help. You guys are great!
 
Don't get me started about those stupid light bulbs.
 
subject: Changing the color of a String...
 
Similar Threads
Is there any means to check the number of objects created when a java prgram runs.
Dynamic class type declaration
Calendar class methods give weird results
How we can find that how much string objects has been created?
Aliter for string formatting - Which is best approach?