aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Deleting a JTable Row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Deleting a JTable Row" Watch "Deleting a JTable Row" New topic
Author

Deleting a JTable Row

Dennis Putnam
Ranch Hand

Joined: Feb 03, 2012
Posts: 210
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

Joined: Jul 08, 2012
Posts: 13
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

Joined: Feb 03, 2012
Posts: 210
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

Joined: Feb 03, 2012
Posts: 210
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deleting a JTable Row
 
Similar Threads
JTable(!!!)
Jtable
JTable & Edit Button Click
Dynamic JTable
JTable