Skip to main content

JTableTree: How to reflect changes to the data model in the UI?

1 reply [Last post]
siva
Offline
Joined: 2003-07-15
Points: 0

Hi, the TreeTableModel extends the TreeModel and not the TableModel. However, the JTreeTable itself extends JTable and not JTree. So, if there are changes in the tree model, how do I reflect it in the ui? I mean, as I can't call tableChanged with a TableModelEvent which requires a TableModel, what do I need to do?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rameshgupta
Offline
Joined: 2004-06-04
Points: 0

> Hi, the TreeTableModel extends the TreeModel and not
> the TableModel. However, the JTreeTable itself
> extends JTable and not JTree. So, if there are
> changes in the tree model, how do I reflect it in the
> ui? I mean, as I can't call tableChanged with a
> TableModelEvent which requires a TableModel, what do
> I need to do?

JXTreeTable has a private TreeTableModelAdapter which is actually a table model that adapts TreeTableModel for use with JXTreeTable. The job of TreeTableModelAdapter is to shield users of JXTreeTable from having to deal with changes to the tree model directly through the TreeModel api. It does this by adding its own TreeModelListener to the underlying TreeTableModel (which is really a TreeModel), and translating each TreeModelEvent into a TableModelEvent. Please search for delayedFireTableDataChanged in JXTreeTable.TreeTableModelAdapter for more details.

Ramesh