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

JTree Expansion

0 views
Skip to first unread message

Marco Stoll

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
I'm using a JTree and trying to programmly expand to a specific Node. I'm
using the JTree.expandPath(TreePath) Method to invoke this action, but
nothing happens.

Anybody got an idea??

Christian Kaufhold

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
Marco Stoll <m.s...@w3design.de> wrote:
> I'm using a JTree and trying to programmly expand to a specific Node. I'm
> using the JTree.expandPath(TreePath) Method to invoke this action, but
> nothing happens.

How are you setting up the TreePath?

Christian

dent...@my-deja.com

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
Ye, you need to refresh the expanded node:

treeModel.nodeStructureChanged(node);
or:
treeModel.nodeChanged(node);


In article <8l6k0g$t03$1...@trinity.hannover.sgh-net.de>,


"Marco Stoll" <m.s...@w3design.de> wrote:
> I'm using a JTree and trying to programmly expand to a specific Node.
I'm
> using the JTree.expandPath(TreePath) Method to invoke this action, but
> nothing happens.
>

> Anybody got an idea??
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.

OODGR

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
"Marco Stoll" <m.s...@w3design.de> wrote in message
news:8l6k0g$t03$1...@trinity.hannover.sgh-net.de...

> I'm using a JTree and trying to programmly expand to a specific Node. I'm
> using the JTree.expandPath(TreePath) Method to invoke this action, but
> nothing happens.
>
> Anybody got an idea??
>


Try scrollPathToVisible(TreePath) instead and optionally
setSelectionPath(TreePath).

--
OODGR

Christian Kaufhold

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
[Quoting arranged to chronological order]

dent...@my-deja.com wrote:
>
> In article <8l6k0g$t03$1...@trinity.hannover.sgh-net.de>,
> "Marco Stoll" <m.s...@w3design.de> wrote:
>> I'm using a JTree and trying to programmly expand to a specific Node.
^^^^

To the OP: Does this mean that the node should become "viewable", but
may possibly be a leaf? Then use makeVisible(). expandPath() silently
(argh!) ignores requests to make leafs viewable.
See the JTree javadoc for the definition of "viewable" and "expanded"
and for that horrible (non-)specification of the behaviour of expand-
Path().

> I'm
>> using the JTree.expandPath(TreePath) Method to invoke this action, but
>> nothing happens.

> Ye, you need to refresh the expanded node:
>
> treeModel.nodeStructureChanged(node);
> or:
> treeModel.nodeChanged(node);

This is relevant to the problem exactly because of?


There are no methods nodeStructureChanged or nodeChanged in TreeModel,
only in DefaultTreeModel. And it is not a requirement to use Default-
TreeModel. So that cannot possibly be any solution, even without know-
ing what these methods might do.

Christian

Timo Rantalaiho

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
In <8l6k0g$t03$1...@trinity.hannover.sgh-net.de> "Marco Stoll" <m.s...@w3design.de> writes:

>I'm using a JTree and trying to programmly expand to a specific Node. I'm


>using the JTree.expandPath(TreePath) Method to invoke this action, but
>nothing happens.

>Anybody got an idea??

This is but a guess, but you could try calling
fireTreeExpanded() or something such as well.

--
Timo.Ra...@helsinki.fi
Help keep Usenet clean: <URL: http://www.hut.fi/u/jkorpela/usenet/dont.html >

0 new messages