File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changing the color of a String...

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Labels support HTML tags, so you could use a FONT tag...

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nathan Pruett is right! Maybe your swing version is low!
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using j2sdk1.4. This should work shouldn't it?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jennifer,
Do you have this problem when you compile and run Nathan's example?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm running under 1.4 also, and I see the HTML tags working...
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic