Article View: borland.public.jbuilder.java.swing
Article #1142Re: adding a node to a JTree
From: Paul Furbacher [TeamB]
Date: Tue, 16 Mar 2004 22:26
Date: Tue, 16 Mar 2004 22:26
40 lines
2070 bytes
2070 bytes
Alan Shiers wrote:
> [...].
>
> My main problem, I am discovering, is that the main JTree on the main
> interface doesn't receive an actual click of the node from the mouse,
> thereby not triggering a TreeSelectionEvent as apposed to when I try to
> delete a node. So, [...]
JTree has methods for translating x,y into rows, path, etc.
The mouse event which pops up your menu gives you x and y.
Pass those values into your method. I think that should
solve your problem.
>>public void createLeafNode(int x, int y)
>> {
>> //jTree1.repaint();
TreePath path = jTree1.getPathForLocation(x, y);
>> if(path == null)
>> return;
>>[...]
>> }
--
Paul Furbacher (TeamB)
Save time, search the archives:
http://www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
Technical Details
Message-ID:
<40577f00@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40564bf4@newsgroups.borland.com> <405752b0@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,a760aeb930adb421 X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2004-03-16 14:40:26 PST Date: Tue, 16 Mar 2004 17:26:09 -0500 From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com> Organization: Reverse Alchemy, Inc. User-Agent: Mozilla Thunderbird 0.5 (Macintosh/20040208) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing Subject: Re: adding a node to a JTree References: <40564bf4@newsgroups.borland.com> <405752b0@newsgroups.borland.com> In-Reply-To: <405752b0@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 68.39.103.120 Message-ID: <40577f00@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1079475968 68.39.103.120 (16 Mar 2004 14:26:08 -0800) Lines: 40 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail