Results 1 to 14 of 14
Like Tree2Likes
  • 1 Post By suhailt
  • 1 Post By suhailt

Thread: how to insert data into jTable in netbeans

  1. #1
    suhailt is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Post how to insert data into jTable in netbeans

    i would like to retrieve data from database and insert it into jtable on netbeans...how to use the jtable.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    suhailt is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: how to insert data into jTable in netbeans

    I have found it's answer that i can use the method setValue of table class ie.
    table1.setValue(vector.elementsAt(1),0,1);
    but i am not able to create new row dynamically ...does anyone know that how can we create dynamic row in netbeans?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: how to insert data into jTable in netbeans

    Quote Originally Posted by suhailt View Post
    I have found it's answer that i can use the method setValue of table class ie.
    table1.setValue(vector.elementsAt(1),0,1);
    but i am not able to create new row dynamically ...does anyone know that how can we create dynamic row in netbeans?
    Again, the information on how to do this is in the tutorial that I've linked to above. It's all about dealing with the JTable's table model.

  5. #5
    suhailt is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: how to insert data into jTable in netbeans

    Quote Originally Posted by Fubarable View Post
    Again, the information on how to do this is in the tutorial that I've linked to above. It's all about dealing with the JTable's table model.
    The link you have given is basic tutorial of java swing..i know how to insert a row into a table without using Netbeans IDE...but my entire project is being done on netbeans...And i am not that much familiar to netbeans as it has it's own way for coding...so please give any links which holds the tutorial of jtable on netbeans IDE...thanks for your helping hands..

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: how to insert data into jTable in netbeans

    It's the same. You get the table model and you add a row to it whether it is done with NetBeans or not.

  7. #7
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,226
    Rep Power
    6

    Default Re: how to insert data into jTable in netbeans

    You need to use the DefaultTableModel. It supports addRow(...) functionality.

  8. #8
    suhailt is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: how to insert data into jTable in netbeans

    see...my table name is jTable1;
    jTable1.getModel().

    The above code is working..but ..i am not able to find any insertRow or AddRow method on the pop menu after the dot of above statement...

  9. #9
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,226
    Rep Power
    6

    Default Re: how to insert data into jTable in netbeans

    You need to cast the TableModel to a DefaultTableModel.

  10. #10
    suhailt is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: how to insert data into jTable in netbeans

    how to use it?

  11. #11
    suhailt is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: how to insert data into jTable in netbeans

    did you mean below code?
    ((DefaultTableModel)jTable1.getModel()).addRow(amo unt,0,1);

    but it's not working...i can see an red underline below the (DefaultTableModel)
    oxford likes this.

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: how to insert data into jTable in netbeans

    Quote Originally Posted by suhailt View Post
    did you mean below code?
    ((DefaultTableModel)jTable1.getModel()).addRow(amo unt,0,1);

    but it's not working...i can see an red underline below the (DefaultTableModel)
    Um... you did import it right?

  13. #13
    suhailt is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: how to insert data into jTable in netbeans

    yes...now it is working...
    import javax.swing.Table.DefaultTableModel;

    thanks for all those helped me to fix the error..t
    oxford likes this.

  14. #14
    oxford is offline Member
    Join Date
    Mar 2014
    Posts
    1
    Rep Power
    0

    Default Re: how to insert data into jTable in netbeans

    addRow(amo unt,0,1) what does these 3 parameters stand for can u tell me plz??

Similar Threads

  1. Replies: 6
    Last Post: 08-16-2011, 09:17 AM
  2. How to insert a row into JTable when filters are used
    By prasad.vara in forum AWT / Swing
    Replies: 0
    Last Post: 10-18-2010, 06:25 AM
  3. Replies: 3
    Last Post: 08-07-2010, 08:06 PM
  4. insert data from text field to jtable
    By mackinas in forum New To Java
    Replies: 2
    Last Post: 06-09-2010, 04:30 AM
  5. Replies: 3
    Last Post: 02-28-2009, 09:17 AM

Tags for this Thread

Posting Permissions

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