title: Error when sorting rows in Jtable
body: <p>I'm trying to set a <code>RowSorter</code> on my Jtable, I used the method <code>setAutoCreateRowSorter(Boolean b)</code> to sort the rows</p>
  
  <pre><code>table.setAutoCreateRowSorter(true);
  </code></pre>
  
  <p>But when I make the table as <code>rawSorted</code>, I get a strange error!</p>
  
  <p>The conflict is visible when I want to delete a line, I used <code>fireTableRowsDeleted()</code>.</p>
  
  <pre><code>int raw = table.getSelectedRow();  // the index of raw that i want to delete it
  System.out.println(raw);
  model.delte_raw(raw); // model is my table model
  
  public void delte_raw(int raw)
           {
               if (!ls.isEmpty()) {
           this.fireTableRowsDeleted(raw+1, raw);
           ls.remove(raw);
           }
  </code></pre>
  
  <p>I want to show you what result return the code as above in 2 cases:</p>
  
  <h2>Case 1:</h2>
  
  <p>When I make my table as not rawsorted:</p>
  
  <pre><code>table.setAutoCreateRowSorter(false);
  </code></pre>
  
  <p>when I delete a line, it all works successfully.</p>
  
  <h2>Case 2:</h2>
  
  <p>When I make my table as rawsorted:</p>
  
  <pre><code>table.setAutoCreateRowSorter(true);
  </code></pre>
  
  <p>when I delete a line, I get the error as below:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Invalid range
      at javax.swing.DefaultRowSorter.checkAgainstModel(DefaultRowSorter.java:921)
      at javax.swing.DefaultRowSorter.rowsDeleted(DefaultRowSorter.java:878)
      at javax.swing.JTable.notifySorter(JTable.java:4277)
      at javax.swing.JTable.sortedTableChanged(JTable.java:4121)
      at javax.swing.JTable.tableChanged(JTable.java:4398)
      at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:296)
      at javax.swing.table.AbstractTableModel.fireTableRowsDeleted(AbstractTableModel.java:261)
  </code></pre>
  
  <p>I think that the error is in my defaultRowSorter, so I defined my specific <code>cellRenderer</code> as below:</p>
  
  <pre><code>//    final TableCellRenderer r = table.getTableHeader().getDefaultRenderer();
  //TableCellRenderer wrapper = new TableCellRenderer() {
  //            private Icon ascendingIcon = new ImageIcon("images/e.png");
  //            private Icon descendingIcon = new ImageIcon("images/e.png");
  //
  //    @Override
  //    public Component getTableCellRendererComponent(JTable table,
  //            Object value, boolean isSelected, boolean hasFocus,
  //            int row, int column) 
  //    {
  //        Component comp = r.getTableCellRendererComponent(table, value, isSelected, 
  //            hasFocus, row, column);
  //        if (comp instanceof JLabel) {
  //            JLabel label = (JLabel) comp;
  //            label.setIcon(getSortIcon(table, column));
  //        }
  //        return comp;
  //    }
  //
  //    /**
  //     * Implements the logic to choose the appropriate icon.
  //     */
  //    private Icon getSortIcon(JTable table, int column) {
  //        SortOrder sortOrder = getColumnSortOrder(table, column);
  //        if (SortOrder.UNSORTED == sortOrder) {
  //            return null;
  //        }
  //        return SortOrder.ASCENDING == sortOrder ? ascendingIcon : descendingIcon;
  //    }
  //
  //    private SortOrder getColumnSortOrder(JTable table, int column) {
  //        if (table == null || table.getRowSorter() == null) {
  //            return SortOrder.UNSORTED;
  //        }
  //        List&lt;? extends RowSorter.SortKey&gt; keys = table.getRowSorter().getSortKeys();
  //        if (keys.size() &gt; 0) {
  //                    RowSorter.SortKey key = keys.get(0);
  //            if (key.getColumn() == table.convertColumnIndexToModel(column)) {
  //                return key.getSortOrder();
  //            }
  //        }
  //        return SortOrder.UNSORTED;
  //    }
  //
  //};
  //table.getTableHeader().setDefaultRenderer(wrapper);
  </code></pre>
  
  <p>But again, the same error!</p>
  
  <p>Why do I get this error? I googled it a lot, but either I used the wrong keywords or there are no simple solutions on the internet.</p>