Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me to use Jtable selection please....  RSS feed

 
tina sow
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I would like to select some lines from a jtable A and put them in another jtable B.Or delete a line from B and put it back in A. Do you know how to do so?
Any code would be great,thanks
Tina
 
aminur rashid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
from the table A first get the selected rows

then remove rows from the model as

the second for loop will be required to syncorized the dynamic deletion.Because say u seleced rows 1 and 2 and in the first for loop ,first row 1 will be deleted and then row 2 will come at the position of row 1 so u can not delete row 2 so the second for loop is required
Now call the repaint()/validate() method to make the deletion visble.
Similarly to insert these rows in table b use insertRow method of model.
In this case u have to first store the data before deleting in a vector and use that vector to set data in table b
Hope i m clear in putting my point
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!