Detect doubleclick on row of TableView JavaFX

后端 未结 6 460
耶瑟儿~
耶瑟儿~ 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:41

    This answer has been tested:

    table.setOnMouseClicked( event -> {
       if( event.getClickCount() == 2 ) {
          System.out.println( table.getSelectionModel().getSelectedItem());
       }});
    

    table.getSelectionModel().getSelectedItem() can be use since we catch a double-click. One the first click the selection moves, on the second this handler is executed.

提交回复
热议问题