TreeItem<String> treeRoot = new TreeItem<String>("Root");
treeRoot.setExpanded(true);
TreeItem<String> exportMr = new TreeItem<String>("Upload to HDFS");
treeRoot.getChildren().add(exportMr);
TreeView<String> treeView = new TreeView<String>(treeRoot);
treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
TreeItem<String> currentSelectItem = (TreeItem<String>) newValue;
if (currentSelectItem != null&& currentSelectItem.getValue()=="Upload to HDFS") {
System.out.println("selection(" + ((TreeItem<String>) newValue).getValue() + ") change");
ModuleDialog md = new ModuleDialog(primaryStage);
}
}
});
treeView.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent mouseEvent)
{
if(mouseEvent.getClickCount() == 2)
{
TreeItem<String> item = treeView.getSelectionModel().getSelectedItem();
System.out.println("Selected Text : " + item.getValue()); if (item.getValue()=="Upload to HDFS") {
ModuleDialog md = new ModuleDialog(primaryStage);
}
}
}
});