java - Changing color character text of a JLabel? -


I am trying to change the color of a JLabel color text

I have a 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".

How can I do this?

I am trying this:

  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", "  ") + "& lt; / body & gt; & lt; / html> "; Jlabel.setText (text);    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -