• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTree/JScrollpane problem

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a problem using the JTree when using a scroll pane.

Basically after clicking on a child node (under the root) the nodes below that expand, however the scroll bar appears and moves down slightly, so that the child node (of the root) is at the top of the window. The root node is hidden now.

Now when I click to collapse the nodes of the child node (of the root) - ie the first line at the top of the window, this code:

int x = e.getX();
int y = e.getY();
int row = tree.getRowForLocation(x, y);
TreePath path = tree.getPathForRow(row);
TreeNode node = (TreeNode)path.getLastPathComponent();

returns row Zero and the node is the root node (which was actually hidden).

It should be returning row = -1 and then just collapse the tree. Instead the click event on the root node occurs.

Please help......

Jerry.
 
Jerry Crothers
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry typo on this line:

Now when I click to collapse the nodes of the child node (of the root) - ie the first line at the top of the window, this code:

Should be:

Now when I click to collapse the nodes of the child node (UNDER the root) - ie the first line at the top of the window, this code:

Jerry.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic