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

  • SEARCH
  • Home
  • 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 3613594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:08:39+00:00 2026-05-18T22:08:39+00:00

Here goes my first question. First of all I’m new with Java and still

  • 0

Here goes my first question. First of all I’m new with Java and still struggling to understand events. I have JTable with a custom model that extends AbstractTableModel, a CustomTableModelHandler that implements TableModelListener and a custom TableCellRenderer in order to show some custom tool tips (combination of data from different columns). The user can only make single row selection and I checked the option autocreaterowsorter. When removing a row I use this method:

public void removeRow(int modelIndex) {
    fireTableRowsDeleted(modelIndex, modelIndex);
    rowData.remove(modelIndex);
}

The reason why I first fire the data change event is that I want to update a JLabel with a text that contains data from the row I’m about to delete (probably there is a more elegant way). I’m always passing the model index row, I’ve tried clearing the selection in the view but that didn’t help. I can’t seem to reproduce the error 100% of the times, but it seems it happens most of the times after I edit a row, there’s a column sorting active and then delete a row (this is actually the action after which the error occurs).

So, the question is: how can I tell what is the cause of my issue? The entire code is a bit too big to post it here, but I can provide it if someone wants to have a look at it.

The error (which appears lots of time):

run:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at Contacts.ContactsGUI$CustomTableModel.getValueAt(ContactsGUI.java:1975)
        at javax.swing.JTable.getValueAt(JTable.java:2686)
        at javax.swing.JTable.prepareRenderer(JTable.java:5703)
        at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)
        at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1974)
        at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1770)
        at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
        at javax.swing.JComponent.paintComponent(JComponent.java:752)
        at javax.swing.JComponent.paint(JComponent.java:1029)
        at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
        at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
        at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
        at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
        at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
        at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
        at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
  • 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-18T22:08:39+00:00Added an answer on May 18, 2026 at 10:08 pm

    The reason why I first fire the data change event is that I want to update a JLabel with a text that contains data from the row I’m about to delete (probably there is a more elegant way).

    This functionality should not be part of the TableModel. The button that invokes the delete logic should save the information you require before invoking the remove row method. Then the removeRow() code should remove the row from your rowData before firing the table rows deleted event.

    but it seems it happens most of the times after I edit a row, there’s a column sorting active and then delete a row

    You need to convert the row view to the row model. I think the code should be something like:

    int modelRow = tableConvertRowIndexToModel( selectedRow );
    rowData.remove(modelRow); 
    fireTableRowsDeleted(modelRow, modelRow);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First question, here goes nothing... I'm trying to add a new entry to my
this is my first question to stackoverflow so here it goes... I use cruise
This question might be kind of elementary, but here goes: I have a SQL
Probably a long question for a simple solution, but here goes... I have a
First post, so here goes. I'm writing a script that does intelligent search and
I'm not sure if this is even possible but here goes: Currently I have
This may seem like a stupid question, so here goes: Other than parsing the
Im new into that asp.net thing, but here goes. I got at ImageButton, and
Ok, this may be a dumb question but here goes. I noticed something the
This is a pretty stupid question, but here goes: Is there a way (in

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.