title: JTable Renderer not working with RowSorter?
body: <p>I have a Simple JTable holding Integers in the first column and Strings in the Second. I would like to be able to sort each Column. </p>
  
  <p>My Renderer:</p>
  
  <pre><code>    package gui.table;
  
  import gui.DaimlerColor;
  
  import java.awt.Component;
  
  import javax.swing.JTable;
  import javax.swing.table.DefaultTableCellRenderer;
  
  @SuppressWarnings("serial")
  public class StandardCellRenderer extends DefaultTableCellRenderer {
  
      @Override
      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);
          c.setBackground((isSelected ?  DaimlerColor.LIGHT_BLUE : (row % 2 == 1 ? DaimlerColor.DARK_WHITE : DaimlerColor.WHITE)));
          if(isSelected){
              c.setBackground(DaimlerColor.LIGHT_BLUE);
          }
          return c;   
      }
  </code></pre>
  
  <p>}</p>
  
  <p>My TableModel:</p>
  
  <pre><code>package gui.table;
  
  import java.util.List;
  import java.util.Vector;
  import javax.swing.table.DefaultTableModel;
  import org.jdom2.Element;
  
  import reporting.FailureClassificationCatalogue;
  
  @SuppressWarnings("serial")
  public class ReportTableModel extends DefaultTableModel {
  
      @Override
      public boolean isCellEditable(int row, int column) {
          return false;
      }
  
      public ReportTableModel(List&lt;Element&gt; reports) {
  
          super(createDataVector(reports), createColumnNames());
      }
  
      private static Vector&lt;Vector&lt;Object&gt;&gt; createDataVector(List&lt;Element&gt; reports) {
  
          Vector&lt;Vector&lt;Object&gt;&gt; data = new  Vector&lt;Vector&lt;Object&gt;&gt;();
          for (int i = 0; i &lt; reports.size(); i++) {
              Vector&lt;Object&gt; row = new Vector&lt;Object&gt;();
              if(reports.get(i).getName().equals("Default")){
                  row.add("-");
              }
              else{
              row.add(Integer.valueOf(i+1));
              }
              String title = reports.get(i).getAttributeValue("type");
              try{
                  title = FailureClassificationCatalogue.valueOf(title).getName();
              }catch(IllegalArgumentException iae){
  
              }catch(NullPointerException npe){
  
              }
              row.add(title);
              data.add(row);
         }
         return data;
      }
  
      @Override
      public Class&lt;?&gt; getColumnClass(int colNum) {
          switch (colNum) {
              case 0:
                  return Integer.class;
              case 1:
                  return String.class;
              default:
                  return String.class;
          }
      } 
  
      private static Vector&lt;String&gt; createColumnNames() {
          Vector&lt;String&gt; columns = new Vector&lt;String&gt;(); 
          columns.add("Number");
          columns.add("Error Type");
          return columns;
      }
  
      /**
       * overridden to ignore null values
       */
      @Override
      public void setValueAt(Object value, int row, int col) {
          if (value == null) {
              return;
          }
          // delegate to the parent method
          super.setValueAt(value, row, col);
      }
  }
  </code></pre>
  
  <p>If I don´t implement the getColumnClass then the renderer works fine but the Integers are sorted as Strings. As soon as I implement the method the renderer doesn´t work properly (background is only set in one column) but the Integers are sorted correctly. How can I resolve this?</p>
  
  <p>My Code to set the renderer and sorter:</p>
  
  <pre><code>reporttable = new JTable();
          reporttable.setName("report");
          reporttable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
          reporttable.setRowHeight(40);
          reporttable.addMouseListener(tgc.mouseListener);
          reporttable.setDefaultRenderer( Object.class, new StandardCellRenderer());
  TableRowSorter&lt;TableModel&gt; sorter = new TableRowSorter&lt;TableModel&gt;();
              reporttable.setRowSorter(sorter);
              sorter.setModel(reportModel);
  </code></pre>
  
  <p>Any ideas? Thanks.</p>