Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Another DefaultTableModel post

 
Przemek Wisniewski
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,

I've got the MySQL "Database" with one table and just a few records in it. I am able to display all the records just fine using "select * from..". However, once displayed when i try to filter/search for something the from the table, I want only the relevant rows to be left/displayed in a table. I am also using the DefaultTableModel's insertRow() method. But it just appends the record in the first row. And it seems like there's no "clear()" method, so I tried to creat new(another) DefaultTableModel inside my search method in order to clear the previous (select * from..) but still no luck.. I have no idea why it won't work. I thought that when i setModel() again it should refresh display? What am I doing wrong?
 
Przemek Wisniewski
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling setRowCount(0) has solved the issue.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!