How to unSelect a JTree??

From: Ramon F Herrera (ramon_at_conexus.net)
Date: 07/23/04


Date: 23 Jul 2004 02:17:50 -0700

I have a problem with JTrees: the user can click away
selecting a set of paths (with the usual <shift> and
<control> keys) but there is no click method that will
restore the tree to its original, pristine, unselected
state.

What I would like to implement is the familiar Mac and
Windows icon selection: when the user clicks on the
desktop all the file icons become unselected.

I figured out how to perform the actual unselection:

  if (tree == leftTree && rightTree.getLastSelectedPathComponent() != null)
    rightTree.setSelectionPath(null);

However, I don't know what event should trigger the above
response. The only Tree Listener seems to be 'valueChanged'
which is fired only when one of the folders is clicked.

How can I detect a click on the background of a tree??

TIA,

-Ramon F Herrera



Relevant Pages

  • Please Help Me Understand This Bizarre Tree Entry Observation
    ... "tree") in one panel populated with directory name nodes. ... Logic for programmatically selecting a previously saved FullPath is ... When I tab into the tree control, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Questions about event handling with Ttk::treeview
    ... have a look at the demo of the treeview. ... Listboxes and Trees->A Directory Tree browser. ... Selecting another item, even without holding down the Shift or Ctrl ... model for the treeview widget. ...
    (comp.lang.tcl)
  • Re: MMC
    ... the tree opens if I right click on the services.msc file and select author. ... and selecting author brings up the one I don't want. ... The wrong one retains its author privileges through a restart. ... >> disabled services, but Norton has reported one exploit two days ago, ...
    (microsoft.public.windowsxp.general)
  • Questions about event handling with Ttk::treeview
    ... I'm trying to write a small Tcl/Tk app with a treeview widget for selecting multiple files and directories in the filesystem. ... Some other GUI toolkits have a "checkbox tree" kind of widget that behaves this way. ... I can keep track of the currently selected items in a variable... ...
    (comp.lang.tcl)