🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Ruben Misrahi Mon, 10 Nov 2003 12:27
TreeModel
#1424
Author: Ruben Misrahi
Date: Mon, 10 Nov 2003 12:27
15 lines
1450 bytes
I have a JTree that is associated with a TreeModel.
The TreeModel uses a TableDataSet to implement its methods:

At some point I modify the TableDataSet and I was expecting the JTree to be
modified as well, but this doesn't happen unless I call:
    jTree1.setModel(null);
    jTree1.setModel(tm); // tm is my implementation to TreeModel

Other than this, things work as expected.
Does anyone know why do I have to de-assign and then re-assign again my
JTree to a model? I would think that the great advantage of the model
approach was precisely that.
(JBuilder7).

Thanks
Re: TreeModel
#1427
Author: Tad Frysinger [TeamB]
Date: Wed, 12 Nov 2003 02:21
27 lines
1988 bytes
Ruben Misrahi wrote:

> I have a JTree that is associated with a TreeModel.
> The TreeModel uses a TableDataSet to implement its methods:
> 
> At some point I modify the TableDataSet and I was expecting the JTree to be
> modified as well, but this doesn't happen unless I call:
>     jTree1.setModel(null);
>     jTree1.setModel(tm); // tm is my implementation to TreeModel
> 
> Other than this, things work as expected.
> Does anyone know why do I have to de-assign and then re-assign again my
> JTree to a model? I would think that the great advantage of the model
> approach was precisely that.
> (JBuilder7).
> 
> Thanks
> 
> 
Because if you change the data that underlies the model without 
notifying the model, then the JTree has no idea what has happened. There 
are various notifications that you can do here. I can point you to the 
online JTree and DefaultTreeModel tutorial sections, or the excellent 
(even if somewhat dated) Geary book on Swing.

-- 
Tad Frysinger [TeamB]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads