I am designing a UI in Netbeans and am having problems getting one of my tables to work. The data in it goes not get updated when I call this method:
public void UpdateTable() {
DefaultTableModel TableModel = new DefaultTableModel();
//(new Object[] { "ID", "Name", "Age" "Sex" "Address" "blah" }, 5)
TableView.setModel(TableModel);
for (Patient k : PatientList) {
String TableID = String.valueOf(k.getAccountNumber());
String TableName = k.getName();
String TableAge = String.valueOf(k.getAge());
String TableAddress = k.getAddress();
String TableSex = k.getSex();
String TablePhone = k.getPhone();
Object[] Col = { "Name", "Code", "age", "blah", "Who", "ghg" };
Object[] Data = { TableID, TableName, TableAge, TableAddress,
TableSex, TablePhone };
TableModel.addRow(Data, Col); //here
JTableHeader header = TableView.getTableHeader();
repaint();
}
System.out.println("Model Set");
TableView.setModel(TableModel);
}
The error is occurring on the line that I commented and I am totally confused as to how to solve this issue.