Javafx Treeview item action event

前端 未结 4 1987
小蘑菇
小蘑菇 2020-12-09 07:06

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 proble

4条回答
  •  甜味超标
    2020-12-09 07:30

    I couldn't find method getPickResult in mouse event, so maybe next is preferable then answer from Alex:

    1) add listener to tree view

    treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> handle(newValue));
    

    2) handle clicks, it's not need distinguish clicks on empty space and nodes

    private void updateSelectedItem(Object newValue) {      
        System.out.println(newValue);
    }
    

提交回复
热议问题