Detect doubleclick on row of TableView JavaFX

后端 未结 6 463
耶瑟儿~
耶瑟儿~ 2020-11-29 21:51

I need to detect double clicks on a row of a TableView.

How can I listen for double clicks on any part of the row and get all data of this row to print

6条回答
  •  广开言路
    2020-11-29 22:47

    This works for me:

    table.setOnMouseClicked((MouseEvent event) -> {
                if (event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2){
                    System.out.println(table.getSelectionModel().getSelectedItem());
                }
            });
        }
    

提交回复
热议问题