Results 1 to 4 of 4
  1. #1
    zam is offline Member
    Join Date
    Mar 2009
    Rep Power

    Default How to add new row from JTable comp in netbeans GUI?

    In these 2 days i had been trying to understand the jTable in order to add new rows in runtime GUI and so far not successful. went through the tutorial from sun tutorial website

    and seems like the tutorial is not using a comp from the pallette in netbeans but creating a new table from scratch. I'm trying to build a GUI and use the jTable as one of the comp. This is different from the tutorial. Since that the jTable comp had been provided, why i still need to create the table from scratch? Can i just use the component? If anyone have idea pls advise..


  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    This is one of the bad results developers comes with who start work from such IDEs, rather not working from the basis.

    In runtime, you have to do the same thing that tutorial explain. You cannot change any properties on the palette at runtime on NetBeans. Go through the tutorial carefully and try to workout a simple application first.

  3. #3
    zam is offline Member
    Join Date
    Mar 2009
    Rep Power


    Yes, it is very painful to start directly to GUI. Anyway, i redo back the concept from (i replaced / with -)

    what i understand, i need to create a table model. But when using GUI, it had been declared automatically when the jTable comp drag to the jForm as under


    private void initComponents() {
    jTable1.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    new String [] {
    "rs1", "rs2", "rs3", "rs4"

    Ok, seems like it had created the table method as DefaultTableModel for it and i believe it is fine now. So i don't need to redo the table method creation. To add a row.. when i check DefaultTableModel class there is a method called addRow(Object[] rowData) - Adds a row to the end of the model.

    Everytime i tried to write jTable.addRow() ... it will have problem. It will now allow me to proceed. I don't really understand here. The table model had been generated and why the addRow method is not able to use from it. Am I missing something here?

    Let me know if I'm still wrong. I just need to add a row to the jTable1 comp which i had dragged to the jForm.


  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

Similar Threads

  1. Netbeans Jtable
    By Manfizy in forum NetBeans
    Replies: 16
    Last Post: 11-13-2008, 09:15 AM
  2. get IP from other comp in LAN
    By hungleon88 in forum Networking
    Replies: 2
    Last Post: 09-20-2008, 01:21 PM
  3. Row Name In Jtable
    By SANDY_INDIA in forum AWT / Swing
    Replies: 1
    Last Post: 08-16-2008, 12:23 AM
  4. Replies: 2
    Last Post: 05-15-2008, 10:15 AM
  5. Replies: 4
    Last Post: 11-27-2007, 11:59 PM

Posting Permissions

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