title: Java: How to I change the color of a specific line or row of string in a Text area?
body: <p>the one way I could change the color is by setForground(). However when there are multiple lines of code it makes everything green or black. Is there another method or any way of solving this problem? Thanks!</p>
  
  <pre><code>int key = evt.getKeyCode();
      if (key == KeyEvent.VK_ENTER)
      {
         String tb1EnterdValue = tb1.getText().toString();
         if((tb1EnterdValue.equals("yes")) )
          {
              TextArea1.setForeground(Color.green);
      else
          {
                TextArea1.setForeground(Color.lightGray);
          }
         this.TextArea1.append("&gt;"+tb1EnterdValue+newline);
         this.tb1.setText("");
  </code></pre>