This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable - tableChanged not firing with AbstractTableModel

 
Marcos Stythe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I've tried various things, but nothing seems to work. Here is my entire class.
My class extends JPanel, implements TableModelListener, and displays a JTable. I create a AbstractTableModel as an inner class which the JTable uses.
I call table.getModel().addTableModelListener(this); thinking it should then add the listener and therefore call tableChanged(...) if changes are made, but this doesn't seem to be the case.
Any help is most appreciated.
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your AbstractTableModel call the fireTable*** methods when the data is changed ? If not, it needs to.
D.
 
Marcos Stythe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to call the tableChanged(..) method when the user edits a cell in the JTable. I am not sure how to go about calling the fireTable* methods when the user edits a cell.
Marcos.
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the user edit a cell, the setValue() method gets called on your TableModel. You should call fireTableCellUpdated() here.
does that help ?
D.
 
Marcos Stythe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YOU BEAUTY!
That ends weeks of torment, thank you very much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic