Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:05:45+00:00 2026-05-14T15:05:45+00:00

I’m trying to delete all entrys from my abstractTableModel. As long as I don’t

  • 0

I’m trying to delete all entrys from my abstractTableModel. As long as I don’t delete the last remaining row, everything works fine, but as soon as I delete this one, I get an ArrayOutOfBoundsException. I’m using a DefaultRowSorter and this seems to be the Exception.

Exception in thread “AWT-EventQueue-0” java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at java.util.Vector.get(Vector.java:694)
at graphics.tableModel.MyTableModel.getValueAt(MyTableModel.java:78)
at graphics.tableModel.MyTableModel.getColumnClass(MyTableModel.java:90)
at javax.swing.table.TableRowSorter.useToString(TableRowSorter.java:224)
at javax.swing.DefaultRowSorter.updateUseToString(DefaultRowSorter.java:607)
at javax.swing.DefaultRowSorter.sort(DefaultRowSorter.java:556)
at javax.swing.DefaultRowSorter.shouldOptimizeChange(DefaultRowSorter.java:1008)
at javax.swing.DefaultRowSorter.rowsDeleted(DefaultRowSorter.java:866)
at javax.swing.JTable.notifySorter(JTable.java:4262)
at javax.swing.JTable.sortedTableChanged(JTable.java:4106)
at javax.swing.JTable.tableChanged(JTable.java:4383)
at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:280)

my Code to delete all Rows:

public void deleteAll() {
 int size = data.size()-1;
 data.clear();
 this.fireTableRowsDeleted(0, size);
}

Same thing happens with simply deleting the last existing row.

public void deleteRow(int row) {
 data.remove(row);
}

the way i’m calling deleteRow:

for (int i = rows.length - 1; i >=0; i--) {

tm.deleteRow(rows[i]);
}

tm.fireTableDataChanged();

thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:05:45+00:00Added an answer on May 14, 2026 at 3:05 pm

    It seems that the problem is in MyTableModel which you use. The model’s getColumnClass() tries to invoke getValueAt() in order to determine the type, but there are no values in the table, thus the exception. So just fix getColumnClass() so that it doesn’t invoke getValueAt(). Normally, the column types are not changing, so you should have something like this:

    public Class<?> getColumnClass(int columnIndex) {
      switch (columnIndex) {
        case 0: return Integer.class;
        case 1: return String.class;
        case 2: return Double.class;
        default: return null;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.