• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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
Hi,

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,
Sourin
 
Bartender
Posts: 1104
10
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.
 
Get me the mayor's office! I need to tell him about this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic