title: Swing - Is it possible to set the font color of 'specific' text within a JTable cell?
body: <p>I have a JTable where one column displays values in the following format:</p>
  
  <pre><code>423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)]
  </code></pre>
  
  <p>I am wondering if it is possible to display the values within square brackets in RED?</p>
  
  <p>I have been googling around for the last few days and have found several examples showing how to set the 'background' of a cell but not really how to change the font of a cell especially not a specific part of the text. </p>
  
  <pre><code>public class myTableCellRenderer
         extends DefaultTableCellRenderer {
    public Component getTableCellRendererComponent(JTable table,
                                                   Object value,
                                                   boolean isSelected,
                                                   boolean hasFocus,
                                                   int row,
                                                   int column) {
      Component c = 
        super.getTableCellRendererComponent(table, value,
                                            isSelected, hasFocus,
                                            row, column);
  
      if (column == 3) {
         c.setForeground(Color.YELLOW);
         c.setBackground(Color.RED);
      }
      return c;
    }
  </code></pre>
  
  <p>Is it really possible to change part of the text to be a different color (i.e. the text that is within the square brackets).</p>
  
  <h2>Edit</h2>
  
  <p>The text i showed as an example is the actual text shown in the table cell (the comma separators are not representing columns). The text displayed in the cell is a comma separated string that i display on the table in column 3. </p>
  
  <p>As an example the table could look like this</p>
  
  <pre><code>product_id |product_name| invoice_numbers
  12         |    Books   | 423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)]
  323        |    Videos  | 423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)]
  4434       |    Music   | 423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)]
  </code></pre>