• 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

FXML Tree event handling example

Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I couldn't find an example of a tree created in FXML using scene builder with proper event handling.
Here's what I am trying to do:
I have created a TreeView using SceneBuilder and want the Tree to display the FileSystem.
I have a controller for this FXML where in the initialize method I am initializing the tree (systemTree) via the following code :

Obviously, I have a custom TreeItem class :

Now here's the problem I am facing:
The tree displays the FileSystem root as a treenode but it does not calls the event handler for the node.
There seems to be some link missing between the FilePathTreeItem and the Tree Node because of which it does not calls the handler method of FilePathTreeItem.
I just can't figure out how to link a mouse click/dblclick event on a tree node via the TreeView to the handler of that FilePathTreeItem.

Can someone please just post a simple Tree example with node event handlers via FXML?

Thanks & Regards,
Posts: 1104
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sourin,
For, all your nodes, you create an instance of your custom class FilePathTreeItem (which is where the event handlers are added), but, for your rootNode, you are only creating an instance of CheckBoxTreeItem. I don't see the event handlers for the root node added anywhere.
Do not set lab on fire. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic