Hi,
I have created a table, and have applied both a cell renderer and cell editor to the same column. I also have overridden the 'isCellEditable()' so that my column is editable. The editor will only allow whole numbers to be entered. So far this is working fine, but when I edit the cell and then move to the next row, the data I entered in the first cell is lost. I have attached some of the code...
What is it that I am missing?
Thanks
Matt
I have created a table, and have applied both a cell renderer and cell editor to the same column. I also have overridden the 'isCellEditable()' so that my column is editable. The editor will only allow whole numbers to be entered. So far this is working fine, but when I edit the cell and then move to the next row, the data I entered in the first cell is lost. I have attached some of the code...
What is it that I am missing?
Thanks
Matt
Code:
//create a template for number fields (align right)
DefaultTableCellRenderer rndNumber = new DefaultTableCellRenderer();
rndNumber.setHorizontalAlignment(JLabel.RIGHT);
tblItems.getColumnModel().getColumn(4).setCellRenderer(rndNumber);
JTextField txtEditor = new JTextField();
txtEditor.setDocument(new GenevaCommon.WholeNumberDocument(6));
TableCellEditor tblEditor = new DefaultCellEditor(txtEditor);
tblItems.getColumnModel().getColumn(4).setCellEditor(tblEditor);