Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sequence of events invoking methods from a tree model

3 views
Skip to first unread message

Jarrick Chagma

unread,
Dec 7, 2009, 5:56:35 AM12/7/09
to
If I invoke methods such as nodeChanged() or nodeStructureChanged() within
my extension of DefaultTreeModel, will the code on the lines immediately
following those calls be executed before or after the view is updated? I am
thinking that those DefaultTreeModel calls will probably queue events that
will be processed on the EDT after the surrounding method completes (which
is obviously also running on the EDT) so the view will not be updated
immediately or in a synchronous manner.

Do I understand this correctly?

--
Regards,

Jarrick

------------------------------------
Jarrick...@your.mind.gmail.com
(Lose your mind before emailing me)

Albert

unread,
Dec 7, 2009, 7:14:32 AM12/7/09
to
Le 07/12/2009 11:56, Jarrick Chagma a �crit :

> If I invoke methods such as nodeChanged() or nodeStructureChanged()
> within my extension of DefaultTreeModel, will the code on the lines
> immediately following those calls be executed before or after the view
> is updated? I am thinking that those DefaultTreeModel calls will
> probably queue events that will be processed on the EDT after the
> surrounding method completes (which is obviously also running on the
> EDT) so the view will not be updated immediately or in a synchronous
> manner.
>

To be sure, you should look at the source code of nodeChanged() and
nodeStructureChanged() to see if there's a call to invokeLater().

Daniel Pitts

unread,
Dec 7, 2009, 2:57:20 PM12/7/09
to
Jarrick Chagma wrote:
> If I invoke methods such as nodeChanged() or nodeStructureChanged()
> within my extension of DefaultTreeModel, will the code on the lines
> immediately following those calls be executed before or after the view
> is updated? I am thinking that those DefaultTreeModel calls will
> probably queue events that will be processed on the EDT after the
> surrounding method completes (which is obviously also running on the
> EDT) so the view will not be updated immediately or in a synchronous
> manner.
>
> Do I understand this correctly?
>
Changes to your TreeModel must only occur on the EDT (or you must
synchronize the changes with the EDT yourself). Most tree listeners do
not call invokeLater or invokeAndWait.

Your TreeModel code shouldn't care about "drawing", it should only care
that your changes are observed by some listener, and that listener can
do whatever they want with that observation.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

0 new messages