I have created a simple JTable with 5 columns, I need to perform validation on the column entries. I have used the getValueAt ( col, row) function to get the values from the columns.

For the first four columns this works without fail but for some reason the last column comes back as null every time. I have searched online to see what I am doing wrong but to no avail.

When I check the columnCount() it returns a value of 5, each row is created by a button action with the following actionPerformed:

String[] student = { "", "", "", "", "" };
students.addRow( student );

where students is a DefaultTableModel instance reading in an array of columnnames as per the following code:

// create a DefaultTableModel to store students
      students = new DefaultTableModel(columnnames,0);

// create a JTable for students DefaultTableModel
      table = new JTable( students );

Any help would be appreciated, I am presuming there is something incorrect in the setting up of the table.

8 Years
Discussion Span
Last Post by Emmett_1981

I actually got it working after all without changing any code, just did a few clean builds and it worked properly, but thanks for the reply! :$

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.