• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic