1 Reply Latest reply on Nov 5, 2012 4:49 AM by 972422

    Retrieving Cell/Row from TableView

      How can I retrieve the selected Cell/Row from a TableView SelectionModel?

      The behavior I want to implement is for the user to right-click the row and enable its edition, right-click again to save. I have done some work using CellFactory, showing textFields when in edition mode AND clicking the cell, but would prefer a cleaner solution.


      Edited by: 965986 on 17/10/2012 14:06

      Edited by: 965986 on 17/10/2012 14:45
        • 1. Re: Retrieving Cell/Row from TableView
          You can try this code :

          table.setOnMouseClicked(new EventHandler<MouseEvent>() {
          public void handle(MouseEvent event) {
          TableView tv = (TableView)event.getSource();
          TablePosition tp = (TablePosition)tv.getSelectionModel().getSelectedCells().get(0);
          int columnIndex = tp.getColumn();
          int rowIndex = tp.getRow();
          tv.getSelectionModel().clearSelection();//I don't know why but the right click mouse seem to alway remember the previous selected cell of the same row.