Java: Paging Leaf Nodes Of JTree

I made a method for a JTree object that will mimic paging features within its leaf nodes. If you have FIRST, NEXT, PREVIOUS and LAST buttons and you click say, NEXT, it will go to the next leaf node of the JTree. If the path to that leaf node is not expanded, it will expand it right away. This is useful in cases wherein you only want the navigation to affect leaf nodes.

The method has 2 parameters: first is the JTree object while the second will require you what kind of paging you want. Either the FIRST, NEXT, PREVIOUS and LAST leaf nodes of the JTree. Here is the code:

To call the method to go to the next leaf node available, you can do it like this:

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *