| 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: 4167
|
|
|
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: 16483
|
|
|
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: 19216
|
|
|
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
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: How do I refresh a jtable after I delete a row?
|
|
|