Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FXML Tree event handling example

 
Sourin K. Sen
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic