🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #10127

No really, I still like JTrees...

#10127
From: Jeff Marendo
Date: Tue, 09 Nov 1999 00:00
36 lines
2003 bytes
I'm trying to create a class that I can use to handle double-click events
generated by a mouse on my JTree.  What I want to do is open certain panels
depending on the string value that a target node holds.  One of my problems
is that I'm not sure how I need to associate the mouseClicked event I'm
making in my mouse listener class with a TreeSelectionEvent variable (to
identify where I'm currently at in the tree).  This is how I'm defining my
mouse listener class, but I know I'm missing a big piece of the puzzle with
regards to TreeSelectionListener and TreeSelectionEvent:

// Define a class that can be used for double-clicking events within the
tree.
  class DoubleClickedMouseListener extends MouseAdapter {
    public void mouseClicked(MouseEvent me) {
      if(me.getClickCount() == 2)
      {
        TreeSelectionEvent event = ???;  // I had 'null' here just to
initialize it, but that was very wrong.
        TreePath path = event.getPath();
        String nodeName = path.getLastPathComponent().toString();
        // getReport(nodeName);
        System.out.println("You double-clicked: " + nodeName);
      }
    }
  }

Down in my code where I'm creating all of my JTree nodes:

MouseAdapter dblClickedListener =
      new DoubleClickedMouseListener();

    if(dblClickedListener != null)
      jTree1.addMouseListener (dblClickedListener);

Can anyone see where I'm going wrong with this?  Thanks in advance.

Jeff
Technical Details
Message-ID: <809rjs$p3r15@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,795280df6ee112a7,start
X-Google-Attributes: gid111d45,public
From: "Jeff Marendo" <marendoj@commos.com>
Subject: No really, I still like JTrees...
Date: 1999/11/09
Message-ID: <809rjs$p3r15@forums.borland.com>
X-Deja-AN: 546557486
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Organization: CommTech Corporation
X-MSMail-Priority: Normal
Reply-To: "Jeff Marendo" <marendoj@commos.com>
Newsgroups: borland.public.jbuilder.java.swing