Is this possible that i can add context menu at TreeItem rather then TreeView in JavaFX

Viewed 8383

i am new to JavaFX. I made the custom TreeCell using this reference:-

http://fxexperience.com/2012/05/listview-custom-cell-factories-and-context-menus/

It perfectly worked for me. But my case is that i do not want to apply this context menu to child nodes. At start there is only single TreeItems and at later stage these TreeItems have child so the try to check isLeaf() method does not make a sense because at starting the TreeItems are at leaf level but later they become parent.

So any idea how can i achieve this.

Thanks a lot.

Update:
At initial stage of my project there is tree having three childs(mail service providers) as follows:-

---Gmail  
---Yahoo  
---Rediff  

After i connect these providers then they have this structure:-

Gmail
   |____Inbox
   |____Sent
Yahoo
   |___Inbox
   |___Sent
   |___Drafts
Rediff
   |___Inbox

Now i want context menu only on Gmail,Yahoo and rediff and not on the inbox or sent item.

I know the setContextmenu() method but this is available for the TreeView and not for the TreeItem.

3 Answers
Related