• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

model.removeRow() from JTable

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am working on the JTable, and i am able to add, edit, delete rows from the table. But when i delete a table and then click the add, then it is not working, it is throwing ArrayIndexOutofBoundException. What i suspecting is, initially the table built with for example 5 rows, and if i delete one row, now it will become 4, but the table not refreshed with 4 rows, so when clicking the add button, it was trying to fetch 5 records. Please let me know how to rectify this problem. I am new to swings.

thanks in advance,
regards,
Sri.
 
sri rallapalli
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using DefaultTableModel.
I am using the functions as model.removeRow(), model.addRow().

regards,
Sri.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure you are passing the correct value for the row index in model.removeRow(int rowIndex)?

If your model has 5 rows and you want to remove the last row, you should be calling model.removeRow(4) and not model.removeRow(5)

Remember, the index starts with 0.

On the other hand,if you are passing the correct index, then you might want to post the part of your code which does the remove operation here to help identify the problem.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic