This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How do I refresh a jtable after I delete a row? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do I refresh a jtable after I delete a row?" Watch "How do I refresh a jtable after I delete a row?" New topic
Author

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

kanika puri
Greenhorn

Joined: Nov 11, 2010
Posts: 4
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

Joined: May 03, 2008
Posts: 4523
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Oct 27, 2005
Posts: 19656
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How do I refresh a jtable after I delete a row?
 
Similar Threads
Making a column invisible in a JTable
how to split "abc-def - ghi-jkl"?
Problem in regular expression for matching
problem in writing Regular Expression
Creating a HTML table to display values from a database