I have 1 window with a collection of students and 1 window where I can add a student. As default I've added 1 row to the table by doing:
DefaultTableModel tableModel = (DefaultTableModel) studentsTable.getModel();
tableModel.addRow(new Object[]{"Sir Student", "M", "email@email.com", "23-04-1921"});
So when I save the student in the other frame I do the following:
studentsFrame overview = new studentsFrame();
overview.addStudent(student);
Where the student
is a new Student()
object with some information about a student.
Well then I'm trying to add the student to the JTable but this doesn't work. I'm not sure what's wrong. When I call this in my constructor is does work. But I want to add it dynamically.
public void addStudent(Student student) {
tableModel.addRow(new Object[]{"New student", "M", "email@new.com", "19-09-1955"});
}
I'm not sure what's going wrong..