• Post Reply Bookmark Topic Watch Topic
  • New Topic

Table Cell retains edited value  RSS feed

Rambo Rambabu
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable in which one column is editable. I created a DefaultCellEditor and did column.setCellEditor().
I also have a ComboBox. When this combobox is changed, I fetch new values from the DB and repopulate the JTable.
For editing any column in the JTable, I have to double click on that column and edit. When I edit and change the combobox, new rows are populated in but the last edited cell retains the value I entered before changing the combo box. Any idea how to stop this from happening?
Also, I have a JText field. The value I enter in this text field has to replicated for a column for all rows in the JTable. I have coded a document listener for the textfield and am using setValueAt() for each row of the JTable to copy this value. It is working fine. But again, just as in above problem, if any column is just Edited and I change the value of JText field, new value is copied for all the rows except for the previously edited cell. Any idea to fix this will be a great help.
thank you,
here is how I popluate the JTable
AdjustmentOrderDetail orderDetail;
if (orderDetailList.size() > 0) {
Iterator it = orderDetailList.iterator();
int testCount = 0;
while (it.hasNext()) {
orderDetail = (AdjustmentOrderDetail) it.next();
Object[] job =
int count = dtm.getRowCount();
here is how I defined the tablecolumn
POSTTextField localTextField = new POSTTextField();
DefaultCellEditor localCellEditor = new DefaultCellEditor(localTextField);
correctedPasscodeColumn = new javax.swing.table.TableColumn();
here is how I copy the textfiled value to a column in the table (for all rows)
POSTTable detailTable = (POSTTable) getControler().getControler(1);
for (int i = 0; i < detailTable.getRowCount(); i++) {
detailTable.setValueAt(correctedPasscode, i, 7);
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jtable.getCellEditor().stopCellEditing() This will force the cell from editing mode so the value will be available.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!