Showing different color texts on a text control in Java

Discussion in 'Java' started by lrantisi, Nov 9, 2006.

  1. lrantisi

    lrantisi Guest

    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, Nov 9, 2006
    #1
    1. Advertisements

  2. lrantisi

    Oliver Wong Guest

    Oliver Wong, Nov 9, 2006
    #2
    1. Advertisements

  3. lrantisi wrote:
    > 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);
     
    RedGrittyBrick, Nov 10, 2006
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Arace

    BGR Color to Java Color

    Andrew Arace, Sep 13, 2003, in forum: Java
    Replies:
    7
    Views:
    8,612
    Stephen Gilbert
    Sep 16, 2003
  2. Matt Adams
    Replies:
    0
    Views:
    1,100
    Matt Adams
    Aug 26, 2003
  3. lrantisi
    Replies:
    0
    Views:
    348
    lrantisi
    Nov 9, 2006
  4. Brendon

    Color property returns Color.Empty to my control

    Brendon, Mar 23, 2005, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    282
    Jason Bentley
    Mar 24, 2005
  5. Robert Sheppard

    User Control not showing font and color

    Robert Sheppard, Oct 31, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    209
    Robert Sheppard
    Oct 31, 2005
  6. Kamaljeet Saini
    Replies:
    0
    Views:
    881
    Kamaljeet Saini
    Feb 13, 2009
  7. Replies:
    7
    Views:
    677
    Mick White
    Feb 2, 2005
  8. Replies:
    1
    Views:
    499
    marss
    Feb 14, 2007
Loading...