CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 1999
    Location
    usa
    Posts
    33

    really need an example of default table model ...

    Help. I am stuck.
    I want to implement a JTable which can addrows to it.

    From
    http://java.sun.com/products/jfc/swi...ableModel.html

    only contain the API.

    i have look around but still cannot find any examples.


    import java.util.Vector;
    //import javax.swing.*;
    //import javax.swing.table.AbstractTableModel;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.event.TableModelEvent;

    what should i put inside this class ?

    public class TModel extends DefaultTableModel {
    Vector data = new Vector();

    }





    http://members.xoom.com/lookads

  2. #2
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: really need an example of default table model ...


    Hi newkid ,

    What's problem with the one i gave ?????

    http://codeguru.developer.com/bbs/wt...va&Number=3264

    insert "import java.util.Vector" "import javax.swing.event.TableModelEvent" in
    the import statement part. If you face any problem post a question or if you want
    something else , please elaborate.

    Poochi....


  3. #3
    Join Date
    Oct 1999
    Location
    usa
    Posts
    33

    just need some example on default table model that can add and delete rows ..

    yes. thanks for the code. but, i thought some of you really could come up with some code that can add and delete rows.

    http://members.xoom.com/lookads

  4. #4
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: just need some example on default table model that can add and delete rows ..


    I dont know what you are really looking for. If you want to add a row in your
    JTable, get TableModel and type cast it to DefaultTableModel and then call addRow(..).
    To delete a row , call removeRow(.. ).

    Ex :



    // Add a row
    ((DefaultTableModel)table.getModel()).addRow( vector );

    // Delete a row
    ((DefaultTableModel)table.getModel()).removeRow( nRowIndex );





    By default , DefaultTableModel is the table model for all JTable. If you set the Model
    to your own Model , then you have to implement all these stuffs( add , remove ..) in your
    TableModel class.

    Poochi...


  5. #5
    Join Date
    Oct 1999
    Location
    usa
    Posts
    33

    Re: just need some example on default table model that can add and delete rows ..

    how does the whole file look like . well, i really need to get it fast and could not afford to read up on the java books.

    really appreciated some java code. hopefully a working demo.

    thanks a lot again.


    http://members.xoom.com/lookads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured