title: Do I have to make a custom implementation of RowSorter when custom insert behavior is needed?
body: <p>I need a JTable with insert behavior that is different the one TableRowSorter/DefaultRowSorter provide.</p>
  
  <p>I need a table such that when user inserts a row, the newly inserted row should go below the one where the cursor was, and cursor placed at the newly inserted row.
  Let me illustrate it on an example:</p>
  
  <p>Initial state - table has 4 rows:</p>
  
  <pre><code>0. Row 1
  1. Row 2 &lt;-- cursor here
  2. Row 3
  3. Row 4
  </code></pre>
  
  <p>User's cursor is at the second row, and user triggers insertion. The newly inserted row appears below, and cursor moves there as well:</p>
  
  <pre><code>0. Row 1
  1. Row 2 
  2. New row &lt;-- cursor here
  3. Row 3
  4. Row 4
  </code></pre>
  
  <p>I understand pretty well that I have two approaches to solve this problem.</p>
  
  <p>First approach is to change my model, so insertion is done at right place in the model. I do not like this solution as it means model indexes will change in all rows below the inserted one. This is the easiest way to accomplish what I need, but, as i said, at the cost of potentially big overhead caused by model indexes change...</p>
  
  <p>Second approach is to implement a RowSorter that will maintain own videToModel[] and modelToView[] arrays and maintain right order when rows are inserted. Naturally, I started by extending TableRowSorter but problem is that modelToView and viewToModel are private arrays and I can't access them so I have problems when rows are filtered...</p>
  
  <p>I am trying to avoid writing my own RowSorter implementation because it will take time to do it right...</p>
  
  <p><strong>UPDATE 2013-10-07:</strong>
  I have accomplished this by implementing my own RowSorter. After experimenting with both approaches I realised the second one gives me more flexibility.</p>