no method to remove all rows from DefaultTableModel

P

Parvinder

A doubt

How do i remove all the rows from a DefaultTableModel.There is a method
to remove a particular row (removeRow(int row)) but no method to remove
all the rows at once..something like model.clear() or model.removeAll()
, etc

Some say that the recommended way of setting a model to a table is
write your table model and supply the data to the table (using
getValueAt()) ..

Does sun recommend this ?

~Parvinder
 
D

David Hilsee

Parvinder said:
A doubt

How do i remove all the rows from a DefaultTableModel.There is a method
to remove a particular row (removeRow(int row)) but no method to remove
all the rows at once..something like model.clear() or model.removeAll()
, etc

Some say that the recommended way of setting a model to a table is
write your table model and supply the data to the table (using
getValueAt()) ..

Does sun recommend this ?

Personally, I hardly ever use DefaultTableModel unless my needs are very
simple. If I'm dealing with custom data types (which is normal), then I
generally find DefaultTableModel to be inconvenient.

There seem to be many options for deleting rows from a DefaultTableModel.
From the method description, a simple setRowCount(0) would seem
satisfactory. Also, the setDataVector() methods seem to be good for
completely replacing the contents of the model. I haven't used either, so
you'll have to give them a shot to see if I'm right.
 
Joined
Jun 15, 2012
Messages
1
Reaction score
0
"Parvinder" <[email protected]> wrote in message
news:[email protected]...
> A doubt
>
> How do i remove all the rows from a DefaultTableModel.There is a method
> to remove a particular row (removeRow(int row)) but no method to remove
> all the rows at once..something like model.clear() or model.removeAll()
> , etc
>
> Some say that the recommended way of setting a model to a table is
> write your table model and supply the data to the table (using
> getValueAt()) ..
>
> Does sun recommend this ?


Personally, I hardly ever use DefaultTableModel unless my needs are very
simple. If I'm dealing with custom data types (which is normal), then I
generally find DefaultTableModel to be inconvenient.

There seem to be many options for deleting rows from a DefaultTableModel.
From the method description, a simple setRowCount(0) would seem
satisfactory. Also, the setDataVector() methods seem to be good for
completely replacing the contents of the model. I haven't used either, so
you'll have to give them a shot to see if I'm right.

--
David Hilsee
Hi David,
What should we use in case of custom data entries..

Thanks in advance

--
Puneet nanda
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top