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.
:)

Can you post the code where you add rows to the table or you change their values?

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! :$

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.