my dog learned polymorphism
The moose likes Java in General and the fly likes Clearing data from a jTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Clearing data from a jTable" Watch "Clearing data from a jTable" New topic

Clearing data from a jTable

Jamie Wool
Ranch Hand

Joined: May 03, 2004
Posts: 49
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

Joined: Dec 07, 2004
Posts: 3
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
I agree. Here's the link:
subject: Clearing data from a jTable
It's not a secret anymore!