Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Clearing data from a jTable  RSS feed

 
Jamie Wool
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an easy way to clear all data from a jTable. I've tried the table.removeAll(), which seemed sensible, but doesn't work.

Also how do you extract a value from a cell into a variable??
 
Vijay Raj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use these methods of DefaultTableModel

1. setDataVector(Vector newData, Vector columnNames)
-- If you want the clear the exisitng contents of the table, pass a empty data vector

2. getValueAt (int row, int column)
-- This method returns the value present in a cell

You can also write your own model by extending AbstractTableModel
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!