java - Changing color character text of a JLabel? -
I am trying to change the color of a JLabel color text
I have a How can I do this? I am trying this: JLabel is text: "JLABEL" and I only want to change the color character "L" After changing, I need "JLABEL" display text with the letter "L".
private zoom character format () {jlabel.setText ("JLABEL"); Four [] t = jlabel.getText (). ToCharArray (); String txtFormat = ""; (Int x = 0; x & lt; t.length; x ++) {if (t [x] == 'L') {txtFormat + = String.format ("& lt; html> Lt; font color = red>% S & lt; / font> & lt; / html & gt; ", t [x]); }} Jlabel.setText (txtFormat); } I do not believe that I think your question is right. To change just one JLables text and highlight the 'L' character in red, you can do the following:
string text = jlabel.getText (); Text = "& lt; html> & lt; body & gt;" + Text.replaceAll ("L", "
Comments
Post a Comment