aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable - tableChanged not firing with AbstractTableModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable - tableChanged not firing with AbstractTableModel" Watch "JTable - tableChanged not firing with AbstractTableModel" New topic
Author

JTable - tableChanged not firing with AbstractTableModel

Marcos Stythe
Greenhorn

Joined: Feb 26, 2004
Posts: 4
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

Joined: Dec 12, 2002
Posts: 580
Does your AbstractTableModel call the fireTable*** methods when the data is changed ? If not, it needs to.
D.
Marcos Stythe
Greenhorn

Joined: Feb 26, 2004
Posts: 4
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

Joined: Dec 12, 2002
Posts: 580
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

Joined: Feb 26, 2004
Posts: 4
YOU BEAUTY!
That ends weeks of torment, thank you very much
 
Consider Paul's rocket mass heater.
 
subject: JTable - tableChanged not firing with AbstractTableModel