aspose file tools*
The moose likes JavaFX and the fly likes FXML Tree event handling example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "FXML Tree event handling example" Watch "FXML Tree event handling example" New topic
Author

FXML Tree event handling example

Sourin K. Sen
Ranch Hand

Joined: May 02, 2006
Posts: 86
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

Joined: Oct 16, 2003
Posts: 1075
    
  10

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.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FXML Tree event handling example
 
Similar Threads
Error while Spliting
trying to get a richfaces tree to populate nodes using data from xml
writing java code that will take data from certian xml <elements> and convert into tree nodes
JTree TreeNode question
richface tree example