0

Setting Font and Colors to different parts of String that is contained in one JLabel

This link provides some previous contexts to this problem.

Basically my program html parses multiple String with same structures

[Ability Name] Range: [Range Number] Cost: [Cost Number] Cooldown: [CD Number].

I save these individual structures into different String variables. And then, I put them into a single JLabel. But I want each of these individual structures with different fonts and colors. Is it possible for me to put in a String Variable inside this html code from the link provided above?

If it is not possible, how could I make this work?

Community
  • 1
  • 1
DHH
  • 97
  • 6
  • If you're asking for HTML in a JLabel, then yes you CAN do so. Java allows some HTML, so you can use `setText(String)` on your JLabel. Use regular HTML Tags for your string, however you cannot use stylesheets, as Java does not support them. – iWumbo Dec 14 '13 at 18:33
  • @iWumbo *"..you cannot use stylesheets, as Java does not support them."* Sure it does. It only implements a *limited range* of the styles defined by W3C, but it certainly supports both in-line and imported CSS. See [this answer](http://stackoverflow.com/a/20584326/418556) for the proof on support for in-line styles. ..I just noticed the OP did indeed **link** to that thread! – Andrew Thompson Dec 14 '13 at 18:35
  • @AndrewThompson Ah, yes....I don't know why I put we cannot use CSS. Sorry about the misinformation. Anyways, my original point is, you can use html as the OP needs it. Sorry again for that. – iWumbo Dec 14 '13 at 18:41

0 Answers0