Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Showing different color texts on a text control in Java

2 views
Skip to first unread message

lrantisi

unread,
Nov 9, 2006, 3:18:25 PM11/9/06
to
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.

lrantisi

unread,
Nov 9, 2006, 3:18:50 PM11/9/06
to

Oliver Wong

unread,
Nov 9, 2006, 3:19:13 PM11/9/06
to
"lrantisi" <lran...@gmail.com> wrote in message
news:1163103505.1...@k70g2000cwa.googlegroups.com...

> 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

unread,
Nov 10, 2006, 3:47:34 PM11/10/06
to

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);

0 new messages