I'm creating a stage that displays a TreeTable that has the following TreeItems: Photos, Files and Videos. When a user selects on one of the items I want the scene to change and display either the photos, files or videos.
Here is a snippet of the TreeTable:
I understand how to get the value of the tree item and display.
public void selectedItem(){
TreeItem<String> item = dataTable.getSelectionModel().getSelectedItem();
if(item != null){
System.out.println(item.getValue());
} else if (item == pngFiles) {
System.out.println("You've selected PNG Files");
}
}
I have also tried to manipulate this code block to have the item variable equal to one of the tree items defined. That didn't work appropriately.
Here is something that may be helpful. You may need
tree.getSelectionModel().selectedItemProperty().addListener
.Edit: You can also do something like the following.
Altered code from https://docs.oracle.com/javafx/2/ui_controls/tree-view.htm.