• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Updating a table cell

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic