title: Adding an Icon to JTable by overriding DefaultTableCellRenderer
body: <p>I'm trying to add an icon to a particular JTable column by specifying my own table cell renderer as below (<a href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html" rel="nofollow noreferrer">based on parts of this tutorial</a>):</p>
  
  <pre><code>public class MyTableCellRenderer extends DefaultTableCellRenderer {
  
      public Component getTableCellRendererComponent(JTable table, Object value,
              boolean isSelected, boolean hasFocus, int row, int column) {
  
          JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  
          if(column == MyTableModel.IMAGE_COLUMN){
              String status = (String)value;
              Icon icon = StatusImageUtil.getStatusIcon(status);
  
              if(icon == null){
                  label.setText(status);
              }else{
                  label.setIcon(icon);
              }
          }
          return label;
      }
  }
  </code></pre>
  
  <p>The above code works but:</p>
  
  <ol>
  <li>All cell have the icon instead of
  the specific one i want specified in
  the if statement</li>
  <li>Cell MyTableModel.IMAGE_COLUMN which
  should only have an icon also has
  text.</li>
  </ol>
  
  <p>Thanks in advance</p>