Article View: comp.lang.java.gui
Article #61Re: extends DefaultMutableTreeNode
From: appdev888
Date: Thu, 21 Jan 1999 00:00
Date: Thu, 21 Jan 1999 00:00
56 lines
3172 bytes
3172 bytes
I have upgraded to use swing 1.0.3 instead of 1.0.2 and my problems went away.
Just thought to share this with you all.
In article <775vqr$t3b$1@nnrp1.dejanews.com>,
appdev888@my-dejanews.com wrote:
> I looked into this more. The mouseClicked method works as far as identifying
> the click, the # of clicks and the closest path for the click; however, the
> expandPath doesn't expand that path at all (unless in the debug mode again).
> The following is a snippet of my code:
>
> // tree is an instance of JTree
> tree.addMouseListener(new MouseAdapter() {
> public void mouseClicked(MouseEvent e) {
> this_mouseClicked(e);
> }
> });
>
> public void this_mouseClicked(MouseEvent e)
> {
> TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
> if (path != null)
> {
> // ReportableEntityNode extends DefaultMutableTreeNode
> ReportableEntityNode node =
> (ReportableEntityNode)path.getLastPathComponent();
> System.out.println("click " + e.getClickCount() + " on "
> + node.getThisEntity().getID_RSSD());
> tree.expandPath(path);
> }
> }
>
> Does anyone have any clue? Thank you!
>
> In article <775fhd$dkj$1@nnrp1.dejanews.com>,
> appdev888@my-dejanews.com wrote:
> > I built a prototype where a hierarchy is built using the
> > DefaultMutableTreeNode directly. I didn't need to build any mouseListener
and
> > the branch explansion worked perfectly.
> >
> > Now I am building the real app. To optimize code reuse, we choose to extend
> > DefaultMutableTreeNode to incorporate our business logic in it. Without
> > building any mouseListener like the prototype, the tree doesn't expand even
> > when I click on it. So we build the mouseListener to the tree itself and it
> > only works as I debug in JBuilder. Does anyone have any idea?
> >
> > -----------== Posted via Deja News, The Discussion Network ==----------
> > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
> >
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Technical Details
Message-ID:
<7882gf$62k$1@nnrp1.dejanews.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<775fhd$dkj$1@nnrp1.dejanews.com> <775vqr$t3b$1@nnrp1.dejanews.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,9d2d9989b39e3103 X-Google-Attributes: gid111d45,public X-Google-Thread: 10fd6d,9d2d9989b39e3103 X-Google-Attributes: gid10fd6d,public From: appdev888@my-dejanews.com Subject: Re: extends DefaultMutableTreeNode Date: 1999/01/21 Message-ID: <7882gf$62k$1@nnrp1.dejanews.com> X-Deja-AN: 435321810 References: <775fhd$dkj$1@nnrp1.dejanews.com> <775vqr$t3b$1@nnrp1.dejanews.com> X-Http-Proxy: 1.0 x6.dejanews.com:80 (Squid/1.1.22) for client 206.138.197.2 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Thu Jan 21 20:26:06 1999 GMT Newsgroups: comp.lang.java.gui,borland.public.jbuilder.java.swing X-Http-User-Agent: Mozilla/4.08 [en] (Win95; U)