I'm trying to create a menu using a treeView. This is the first time I'm using treeView and have been reading up on it on several websites.
I'm having some problems when it comes to action event. What I want to do is basically to fire and event when ever the user clicks a node in the treeview so far I have the following:
TreeItem<String> rootItem = new TreeItem<String>("Navigation");
TreeItem<String> statistics = new TreeItem<String>("Statistics");
TreeItem<String> clan = new TreeItem<String>("Clan page");
clan.addEventHandler(MouseEvent, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// TODO Auto-generated method stub
}
});
rootItem.getChildren().add(statistics);
rootItem.getChildren().add(clan);
TreeView<String> tree = new TreeView<String>(rootItem);
Sadly this doesn't seem to work.
Is there any way I can add a clicklistener
or even an actionlistener
to the individual items in my treeView
without changing the treeItems
to type Button
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…