title: How to set different colors to ArrayList content in Java
body: <p>I am scanning the files with different extension and putting them in String  ArrayList in Java(the names with extension). I want to print with different colors into JTextArea by looking the extesions for example .xls extension as green color , .txt extension as blue color. Here is my code below ; </p>
  
  <pre><code>public void setScanResult(ArrayList&lt;String&gt; x)
  {
      textArea.append("|");
  
      for (int i = 0; i &lt; x.size(); i++) {                
          textArea.append("\n");
          textArea.append((String) x.get(i));                
      }    
      x.clear();
  }
  </code></pre>