• 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Need Help with editing/updating JTable list by clicking on cell values

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! So I am making progress with my program but now I need to update the database by clicking into a cell and changing the value. But I need it to update to the database with the inserted value as well. I have googled, but a lot of them are describing things like using a function like isCellEditable which I think is built in?  I cannot really find how to use this code in conjunction with a database.

Thanks!

Here is the code I am working with:


 
Rancher
Posts: 3163
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add a TableModelListener to the TableModel of your JTable.

When data in a cell is changed an event will be generated and you can then update your database.

See this answer for an example.

Or you may want to use a Table Cell Listener instead of the TableModelListener, for the reasons listed in the link.

 
Adam Grey
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, the link that says answer is not leading me anywhere. Thanks!
 
Marshal
Posts: 25483
67
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I edited Rob's post so that the link works (just a minor formatting problem).
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic