• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I refresh a jtable after I delete a row?

 
kanika puri
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I refresh a jtable after I delete a row?

Currently my jtable for example is :

abc|111|123

def|111|123

ghi|111|123

jkl|111|123

mno|111|123

But when I delete say example the 5th row :

my new table should show

abc|111|123

def|111|123

ghi|111|123

jkl|111|123

BUT instead it shows

abc|111|123

def|111|123

ghi|111|123

jkl|111|123

jkl|111|123

Can anyone tell me how to refresh the table correctly after a row is deleted?
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post a SSCCE that demonstrates the problem. Don't forget to use the code tags so that your code retains its formatting.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a properly written table model, then it will automatically refresh the view (the JTable) when it is modified. I believe the DefaultTableModel does that, for example. Of course you would have to delete the row from the table model, and you didn't say you were doing that. A description of the problem would be helpful (and pay attention to Darryl Burke's suggestions too).
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to fire the proper events for TableModelListeners. DefaultTableModel does that for you; if you extend AbstractTableModel you can call one of the fireXXX methods when you modify the contents of the model.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic