• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Determining next visible leaf in a JTree

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given a partially expanded JTree, I'm trying to determine the next visible leaf from the currently selected tree node. This may or may not be a child/sibling of the current node, and could easily have multiple nodes expanded.
I have two ideas doing this.
Option 1:
View the JTree simple as a single columned table, and find the next leaf 'down' the column, irresepective of parent. The problem here, is that I'm having difficulty determining row number, and i'm not even sure if that is the right way to do this
Option 2:
Write some ridiculously complex traversing logic that goes 'up' and 'down' parent/child/sibling nodes, hunting for the next visible leaf. I've tried using nextLeaf and other similar methods, but there is no distinction between leaves in collapsed or expanded nodes.
I'd really really like to do Option 1, (or at least fully investigate it before attempting Option 2) just because it seems both the easiest to implement and the most concise logic.
Thanks in advance, and sorry this is a bit of a long one! :-)
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given a node in the tree, next visible node (downwards) should be
either 1) it's sibling or
2) sibling of it's parent.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic