Is there a text control in Java that I can use to show texts with
different colors at the same time. Like showing a word in Red and
another one in blue at the same time on that control.
Oliver Wong - 09 Nov 2006 20:19 GMT
> Is there a text control in Java that I can use to show texts with
> different colors at the same time. Like showing a word in Red and
> another one in blue at the same time on that control.
See
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
- Oliver
RedGrittyBrick - 10 Nov 2006 20:47 GMT
> Is there a text control in Java that I can use to show texts with
> different colors at the same time. Like showing a word in Red and
> another one in blue at the same time on that control.
Lots.
String labelText =
"<html>Foo " +
"<font color=\"red\">bar</font>" +
" baz " +
"<font color=\"blue\">qux</font>" +
" quxx " +
"</html>";
JLabel label = new JLabel(labelText);
aPanel.add(label);