File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing the color of a String...