developer
developer

Reputation: 9478

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

Upvotes: 1

Views: 395

Answers (2)

user1771927
user1771927

Reputation: 16

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

Upvotes: 0

MadProgrammer
MadProgrammer

Reputation: 347184

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

Upvotes: 5

Related Questions