Article View: borland.public.jbuilder.java.swing
Article #8846Re: jtree
From: Ian Atkinson
Date: Mon, 03 Jul 2000 00:00
Date: Mon, 03 Jul 2000 00:00
40 lines
1830 bytes
1830 bytes
i am doing something similar (pulling data in on request that is), i use
the treeWillExpand event of the JTree and it works well. i do the
following:
void treLocation_treeWillExpand(TreeExpansionEvent e) throws
ExpandVetoException
{
TreePath trpPath = e.getPath();
if(trpPath != null)
{
// get the ending node
FileNode node = (FileNode)(trpPath.getLastPathComponent());
// first, make sure its not a leaf, these can't be expanded
if(!node.isLeaf())
{
// get the children for this node that is being opened
retrieveNodeChildren(trpPath);
// fire a structure changed event for this node so that
any
// new nodes will be displayed in the tree
((DefaultTreeModel)treLocation.getModel()).nodeStructureChanged(node);
}
else
{
throw new ExpandVetoException(e, "Can not expand a
leaf");
}
}
}
the actuall pulling of data in and node addition is done in
retrieveNodeChildren
ian
Technical Details
Message-ID:
<3960C2C0.B513C29E@labs.mot.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<39607c13_1@news.arcor-ip.de>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,af9255aa95ccefe0 X-Google-Attributes: gid111d45,public From: Ian Atkinson <atkinson@labs.mot.com> Subject: Re: jtree Date: 2000/07/03 Message-ID: <3960C2C0.B513C29E@labs.mot.com> X-Deja-AN: 641897940 Content-Transfer-Encoding: 7bit References: <39607c13_1@news.arcor-ip.de> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: postmaster@mot.com X-Trace: schbbs.mot.com 962642403 19361 182.1.83.2 (3 Jul 2000 16:40:03 GMT) Organization: Motorola Mime-Version: 1.0 NNTP-Posting-Date: 3 Jul 2000 16:40:03 GMT Newsgroups: borland.public.jbuilder.java.swing