This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable Problem Since 1 week  RSS feed

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have table which populates data from the data base now the problem is when ever i click the button the old rows are not erased from the JTable and the new once are added below them. Here is my code can any body just modify it.
Thanks and regards

i have tried using repaint() and revalidate but nothing works.
 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by adeeb alexander:
hi,
i have table which populates data from the data base now the problem is when ever i click the button the old rows are not erased from the JTable and the new once are added below them.



No wonder.
You are picking the existing model and adding rows to it.


What you need to do is create a new table model, populate it with data from your DB and then set it on the table.
OR
Take your existing model, delete all existing data and repopulate with new data from the DB.
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Manish can you please tell how can i delete all existing data and repopulate with new data from the DB.Please add that line of code in the code i gave before please.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by adeeb alexander:
..Please add that line of code in the code i gave before please.



I am absolutely tempted to use abusive language. You think I got nothing better to do? Have you bothered to at least go through the API before asking me to do stuff for you?
 
Sheriff
Posts: 21308
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No he hasn't.

adeeb, I've warned you before - ShowSomeEffort and SearchFirst. You still keep posting every single question you have on this board without any hint that you are even aware the API exists.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!