Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

2 JTables with different behaviour, but 1TableModel  RSS feed

 
Clara Zetkin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I've got these two JTables, and because they are using the same TableModel:
jTable1 = new JTable(myTableModel)
and the TableModel fires:
fireTableChanged(null) when the data is changed,
they both display the same data.
But I want only one table to get updated, and the other not, but because I need the data at first, I have to use the TableModel. How can I remove the TableModelListener from the one Table but not from the other?
Thanks for any suggestions!
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could try

As the table model controls all the data flow in the table, I would prefer to write to table models for the two tables. you could use composion and just stop the event notification. so when table model 1 notifies table 1, table model 2 does not notify table 2 (Decorator pattern). But you would still have a table model for table 2 which is a fine thing.

Chantal
 
Clara Zetkin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, it works with the 2 different Models.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!