简体   繁体   中英

Unable to refresh JTable content after inserting data

I am implementing JTable as user registration form, I am almost done, but when an data is added its not showing latest data entered and also the size of JTable is very small. How can i increase that?

code is in below link JTable Implementation

Your table won't magically know when you've added data unless you tell it.

Take a look at DefaultTableModel#addRow

Once you've inserted your new row into the data base, you need to add it to the table model.

Take a look at How to Use Tables

use this

DefaultTableModel myData = new DefaultTableModel();
JTable table = new JTable(myData);

// initialize the table with model type constructor

   String offer = "pankaj ";
    Object [] rowData=new Object[]{offer,null};

//convert string into object array myData.addRow(rowData);

//use addRow(Object[] rowData) method of defaulttablemodel class

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