Every example I can find either goes through creating a table without a gui or explains how to populate from a database. I must be missing something simple but here’s what I have so far based off of different tutorials and at How to Use Tables: Creating a Table Model.
private void btnAddRecordToTableActionPerformed(java.awt.event.ActionEvent evt) {
String strPledgeArray[][] =
{
{"1","2","3","4","5"}
};
String columnNames[] = {"Column 1", "Column 2", "Column 3","Column 4","Column 5"};
JTable tblDataGridResults = new JTable(strPledgeArray, columnNames);
}
After pressing the button nothing happens however. What am I doing wrong?
From my reading I think it’s because there’s no model but every time I see anything about models they are in different classes or using constructors that just create errors in my program.
1) code line
create a new JTable that isn’t added to the GUI
2) better would be to add ColumnNames and Rows to the DefaultTableModel, please read in the tutorial how TableModel works
EDIT
still don’t understand ???