Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Table Cell retains edited value  RSS feed

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);
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);
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.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!