• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deleting a JTable Row

 
Dennis Putnam
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am on to the next layer of the onion, namely deleting rows from a JTable. I figured out the hard way that having sortable columns requires I use convertRowIndexTableToModel to get the proper index for the selected row(s). After going through all the machinations associated with deleting the selected row(s), I need to actually remove them from the JTable itself. It is not clear what I need to do to do that (other than I need to delete high to low indexes). By the time I reach that point the original selection has been converted so do I need to call some (currently unknown) function to covert back or do I use the converted row index and should I have saved the unconverted index(s)? Also does the converted row index take into account a zero base or do I need to subtract 1? I did get an out of range exception using the converted row index. It was 1 greater than the max according to the trace back. TIA.
 
Veena Nair
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
i didn understand your question properly.. But from what i understood you are trying to delete few rows after having performed "convertRowIndexToModel()" opearation..
So, having performed the convertion to "Table Model " now indices of the underlying data would have been changed(if you have performed some sort of re_arrangement)... & the view as well as the real arrangement will also be the same... Thus you can delete it as such.. The original rows which you selected will only be deleted...!
Im also a beginner in Swings..! & im not at all sure about my comment ..! ... !
Now Lets wait for some Expert Answers..!!
 
Dennis Putnam
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found part of my answer. There is an opposite function called convertRowIndexToView. However, it is still not clear which I should use.
 
Dennis Putnam
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had to rethink my logic for deleting what I needed from the table and had to change my logic so this question is now moot. I have a related but different question so I'll start a new thread. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic