🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Erica Wheatcroft Mon, 31 Jan 2005 21:17
JTree / Multi-Select
#700
Author: 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.
Re: JTree / Multi-Select
#701
Author: John McGrath [TeamB]
Date: Tue, 01 Feb 2005 05:42
17 lines
1431 bytes
On 1/31/2005 at 4:17:47 PM, Erica Wheatcroft wrote:

> However if the user has selected multiple nodes the popup menu only
> highlights the last node selected when displaying the popup menu.

>       _recipeTree.setSelectionPath ( path );

You are setting the selection to the node that the user clicked on.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads