🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

JTree / Multi-Select

#700
From: Erica Wheatcroft
Date: Mon, 31 Jan 2005 21:17
37 lines
2051 bytes
Hi -

I've created a Jtree that allows for Discontinuous tree selection and I want 
to instantiate a popup menu when the user right clicks. The code I have 
written works fine with a single node selected. However if the user has 
selected multiple nodes the popup menu only highlights the last node 
selected when displaying the popup menu.

This is the editTree() function that is called when mouse pressed or mouse 
released event is caught.

 private void editTree(MouseEvent e)
  {
    // we only want a to do this if the event is a pop up trigger.
    if(e.isPopupTrigger())
    {
      int xCoord = e.getX ();
      int yCoord = e.getY ();

      // get the path that was selected
      TreePath path = _recipeTree.getPathForLocation ( xCoord, yCoord );
      // as long as the user has selected something select the path.

      if ( path == null )
        return;

      _recipeTree.setSelectionPath ( path );
      _recipeTree.scrollPathToVisible(path);

      _treePopupMenu.show ( e.getComponent (), xCoord, yCoord );
    }

  }

any suggestions?

Thanks in advance.
Technical Details
Message-ID: <41fea07a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed-east.nntpserver.com!nntpserver.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,47fb62d6f56d9f83,start
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Erica Wheatcroft" <erica.wheatcroft@gmail.com>
From: "Erica Wheatcroft" <erica.wheatcroft@gmail.com>
Newsgroups: borland.public.jbuilder.java.swing
Subject: JTree / Multi-Select 
Date: Mon, 31 Jan 2005 15:17:47 -0600
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
NNTP-Posting-Host: 206.127.10.170
Message-ID: <41fea07a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1107206266 206.127.10.170 (31 Jan 2005 13:17:46 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed-east.nntpserver.com!nntpserver.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail