Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating a table cell

 
josine wilms
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I change something in my table, stay in the cell, and push the <save> button to update the data in that cell / row, it won't update the information in the cell I'm in, unless I go to another cell....

What do I need to do to change that? Is there a suitable listener, should I change the focus when pushing the update button?

Thnx,
Josine
 
Ed Tse
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you click on the button, did you call fireTableDataChanged() on the TableModel? The JTable has a listener on the TableModel.
 
Pablo Aravena
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should use the repaint method after changing the data in your TableModel something like:

recordTableModel.setValueAt(value, row, column);
mainTable.setModel(recordTableModel);
mainTable.repaint();

I hope this can help you

good luck
 
Fola Fadairo
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have the solution to this problem? I have searched the forum and the best I have come up with, is to use a JTextField to enter the new owner ID. I would rather keep my GUI layout as it is.
I know a solution exists because I have seen many threads on this theme, but the solution was never posted.

Thanks.
 
Fola Fadairo
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution and it goes:



The code should be called for the cell where the owner id is entered. I make the call in the EventListener whenever the 'Book' button is clicked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic