🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java.gui
Article #63

Re: extends DefaultMutableTreeNode

#63
From: appdev888
Date: Fri, 08 Jan 1999 00:00
46 lines
2692 bytes
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    
Technical Details
Message-ID: <775vqr$t3b$1@nnrp1.dejanews.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <775fhd$dkj$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/08
Message-ID: <775vqr$t3b$1@nnrp1.dejanews.com>
X-Deja-AN: 430308456
References: <775fhd$dkj$1@nnrp1.dejanews.com>
X-Http-Proxy: 1.0 x5.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: Fri Jan 08 22:11:41 1999 GMT
Newsgroups: comp.lang.java.gui,borland.public.jbuilder.java.swing
X-Http-User-Agent: Mozilla/4.06 [en] (Win95; U)