no method to remove all rows from DefaultTableModel

Discussion in 'Java' started by Parvinder, Aug 19, 2004.

  1. Parvinder

    Parvinder Guest

    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
    Parvinder, Aug 19, 2004
    #1
    1. Advertising

  2. Parvinder

    David Hilsee Guest

    "Parvinder" <> wrote in message
    news:cg1a1a$...
    > 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
    David Hilsee, Aug 19, 2004
    #2
    1. Advertising

  3. Parvinder

    PuneetNanda9

    Joined:
    Jun 15, 2012
    Messages:
    1
    Hi David,
    What should we use in case of custom data entries..

    Thanks in advance

    --
    Puneet nanda
    PuneetNanda9, Jun 15, 2012
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aloys Oberthuer
    Replies:
    3
    Views:
    7,459
    Aloys Oberthuer
    Apr 22, 2004
  2. Deshaies
    Replies:
    3
    Views:
    4,515
    Deshaies
    Apr 20, 2004
  3. Cyril Dex

    DefaultTableModel

    Cyril Dex, Sep 20, 2004, in forum: Java
    Replies:
    2
    Views:
    3,686
    Nigel Wade
    Sep 21, 2004
  4. Peter
    Replies:
    2
    Views:
    2,977
    Andrew Thompson
    Jan 4, 2005
  5. Peter

    extends DefaultTableModel ?

    Peter, Jan 3, 2005, in forum: Java
    Replies:
    0
    Views:
    656
    Peter
    Jan 3, 2005
Loading...

Share This Page