简体   繁体   中英

How do you add data to a new row in a java swing table?

I have created a new table row with the below code, however I am having trouble populating that row with data. How would one go about adding data to the new table row?

    DefaultTableModel model = (DefaultTableModel) this.jTable1.getModel();
    Object[] row = new Object[4];

Got outside help - here's the solution for posterity;

        DefaultTableModel model = (DefaultTableModel)
        this.jTable1.getModel();     
        Object[] row = new Object[4];
        row[0] = newUser;
        row[1] = newPass;
        row[2] = newDept;
        row[3] = newTel;

        model.addRow(row);

Note: Replace variables with what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM