Results 1 to 3 of 3
Thread: Remove Jtable rows
- 09-17-2010, 04:56 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 88
- Rep Power
- 0
Remove Jtable rows
How to remove multiple rows of JTable using for loop?
The situation is user selects the row it contain key, if a row match that key delete the row.
i implement the the idea following way
but problem is after removing row table row is less by one and the row move up, and few rows are unchecked change in the row please help me how to remove the multiple rows with a loop .Java Code:String key=jtable.getValueat(jtable.getSelectedRow(),0).toString(); for(int i=jtable.getSelectedRow()+1; i<jtable.getRowCount(); i++) { String value=jtable.getValueat(i,0).toString(); if(key.equals(value)) { jtable.getModel().removeRow(i); } }Last edited by anilkumar_vist; 09-17-2010 at 04:59 AM.
- 09-17-2010, 06:47 AM #2
Iterate in reverse, from the last row to the first.
db
- 09-17-2010, 08:03 AM #3
Member
- Join Date
- Oct 2009
- Posts
- 88
- Rep Power
- 0
Similar Threads
-
Listening rows in JTable ??
By Stephen Douglas in forum New To JavaReplies: 2Last Post: 04-10-2010, 04:45 PM -
Highlight rows of a jtable
By simmi in forum AWT / SwingReplies: 5Last Post: 08-20-2009, 01:13 PM -
JTable, deselecting rows gives ArrayIndexOutOfBoundsException
By hendrix79 in forum New To JavaReplies: 0Last Post: 01-23-2009, 04:36 PM -
Deleting All rows in the JTable
By surot in forum New To JavaReplies: 1Last Post: 04-16-2008, 10:44 AM -
display rows in jtable
By osval in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 08:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks