Hi!
I have a problem with the array of JTextField components. So, the code is shown below and it can be successfully compiled:
txtAdminTextFields = new JTextField[nrOfCols];
...
tableAttributes.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
public void columnMarginChanged(ChangeEvent e) {
for (int i=0; i < nrOfColsFin; i++) {
txtAdminTextFields[i] = new JTextField();
txtAdminTextFields[i].setPreferredSize(new Dimension(tableAttributes.getColumn(dbColName[i]).getPreferredWidth(),txtAdminTextFields[i].getPreferredSize().height));
}
}
public void columnAdded(TableColumnModelEvent e) {}
public void columnRemoved(TableColumnModelEvent e) {}
public void columnMoved(TableColumnModelEvent e) {}
public void columnSelectionChanged(ListSelectionEvent e) {}
});
...
// THE ERROR MESSAGE OCCURS AFTER EXECUTING THE CODE BELOW!
// "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
for (int i=0; i < nrOfColsFin; i++) {
if (i != nrOfColsFin) {
attrPan.add(txtAdminTextFields[i]);
} else if (i == nrOfColsFin) {
attrPan.add(txtAdminTextFields[i], "wrap");
}
}
Please, help me to solve the problem.