Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

TableModelListener not triggered  RSS feed

 
Daniel Lawton
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to make a program that allows the user to edit cells in a JTable by double clicking the cell and this should then update the JTable/TableModel and send this to the original MySQL table.

The issue I'm having is that my TableModelListener is not being triggered when one edits the cell in the JFrame.

I have got it to the point where it successfully truncates the table, but no data is input.

Here is the code.


 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I expect that's because the table you are modifying (the one which you can see) is not the table to which you added the listener. What's up with the variable "newTable" which you create at line 41 of your posted code?
 
Daniel Lawton
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I expect that's because the table you are modifying (the one which you can see) is not the table to which you added the listener. What's up with the variable "newTable" which you create at line 41 of your posted code?


I forgot to edit this part out of the question, sorry.

I was messing around with trying to save it to another JTable instead of the original, however I changed this back to saving the change over the original.

This means that the newTable has no meaning anymore
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't understand how your question relates to that code. You have a button, and when that button is pressed you create a whole new window which contains a JTable, and you fill that table from an SQL query. Right?

So is your problem that people are supposed to be able to edit that JTable which you created there? And if they do, then your table model listener is supposed to be immediately notified about those edits? But then your new window has a Save button which one would think would take the entire contents of the table model and refresh the database, so I don't understand the purpose of listening for edits.

Anyway if that isn't your current code it would help to post the current code and ask a question about that code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!