Article View: borland.public.jbuilder.java.swing
Article #829Re: How to UnSelect a JTree?
From: John McGrath [TeamB]
Date: Mon, 02 Aug 2004 07:44
Date: Mon, 02 Aug 2004 07:44
25 lines
1776 bytes
1776 bytes
On 7/24/2004 at 10:21:42 PM, Ramon F Herrera wrote:
> However, I don't know what event should trigger the above
> response. The only Tree Listener seems to be 'valueChanged'
> which is fired only when one of the folders is clicked.
>
> How can I detect a click on the background of a tree??
JTree is derived from JComponent and Component, so it inherits all of
their methods. If you check Component, you will find the
addMouseListener() method.
You will need to add a MouseListener and respond to one of the MouseEvents
(mousePressed, mouseReleased, mouseClicked), and determine if the mouse
position is pointing to one of the JTree's nodes. I think you should be
able to use the JTree getRowForLocation() method to do that.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<410df0f3$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41031939$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,2aac51bc857db07c X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit From: "John McGrath [TeamB]" <ng-b@JPMcGrath.net> Subject: Re: How to UnSelect a JTree? Newsgroups: borland.public.jbuilder.java.swing References: <41031939$1@newsgroups.borland.com> User-Agent: XanaNews/1.16.3.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 NNTP-Posting-Host: 151.197.202.89 Message-ID: <410df0f3$1@newsgroups.borland.com> Date: 2 Aug 2004 00:44:51 -0700 X-Trace: newsgroups.borland.com 1091432691 151.197.202.89 (2 Aug 2004 00:44:51 -0700) Lines: 25 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail