Results 1 to 3 of 3
  1. #1
    swat_katz is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default Unable to use fireTableRow after adding sorter on JTable

    Hi,

    I have a JTable that uses MyTableModel that extends AbstractTableModel. I am also using TableRowSorter on the JTable.

    Then, on clicking of a button, I do this:
    String key = tmodel.sessionIds.get(0);
    tmodel.attributeMap.remove(key);
    tmodel.sessionIds.remove(0);
    tmodel.fireTableRowsDeleted(0,0);

    where tmodel is an instance of the Table model. Basically sessionIds and attributeMap store the data for the model. I get the following exception on frireTableRowsDeleted:
    Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Invalid range
    at javax.swing.DefaultRowSorter.rowsDeleted(Unknown Source)
    at javax.swing.JTable.notifySorter(Unknown Source)
    at javax.swing.JTable.sortedTableChanged(Unknown Source)
    at javax.swing.JTable.tableChanged(Unknown Source)
    at javax.swing.table.AbstractTableModel.fireTableChan ged(Unknown Source)
    at javax.swing.table.AbstractTableModel.fireTableRows Deleted(Unknown Source)
    at JTop$ButtonListener.actionPerformed(JTop.java:268)

    I have been trying to resolve this error for the past 2 days now. Please help!!

    Thanks,
    Swati

  2. #2
    swat_katz is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default

    Ok. The problem still exists and the solution that I found by sheer chance is that if I do tmodel.modelStructureChanged(), then i no longer get the exception. I can't understand why is that because the model structure did not change

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Sorry for my ignorance, but where are you getting the sessionsIds and attributeMap fields? I've not heard of AbstractTableModel or even DefaultTableModel having these fields.
    Last edited by Fubarable; 04-10-2009 at 12:01 AM.

Similar Threads

  1. easy wayto adding jcomponent to a jtable cell
    By aruna1 in forum New To Java
    Replies: 7
    Last Post: 03-30-2009, 07:36 AM
  2. how to use sorter on JTable
    By sunilpatel28 in forum Advanced Java
    Replies: 1
    Last Post: 12-09-2008, 11:18 PM
  3. how to use sorter on JTable
    By sunilpatel28 in forum Advanced Java
    Replies: 0
    Last Post: 12-09-2008, 08:24 AM
  4. Replies: 2
    Last Post: 05-15-2008, 10:15 AM
  5. Adding information to a JTable in a JTabbedPane
    By bigpappatrader in forum AWT / Swing
    Replies: 0
    Last Post: 12-05-2007, 07:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •