0

I have set TextField in column as below in Tableview setGraphic(textField); then I have added changeListener to get updated text, so now I also want to get row and column number.

setGraphic(textField); 
textField.textProperty().addListener(new ChangeListener<String>() {
 public void changed(final ObservableValue<? extends String> observableValue,
         final String oldValue,final String newValue) 
    { 
      System.out.println("old "+oldValue+" and new : "+newValue); 
  // Here,How can i get the particuler row number
 } });
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96
Ifran
  • 1
  • 1
  • 2

1 Answers1

2

Assuming that you are selecting one TableView cell, and you want to get its column and the row index.

Get the TableView from your TableCell:

TableView table = this.getTableView();

Then, the TablePosition from the first SelectionModel:

   TablePosition firstCell = table.getSelectionModel().getSelectedCells().get(0);

Finally, the column and row index :

 firstCell.getColumn() //int
 firstCell.getRow()  //int
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96
  • No, I am not selecting any row .In every row I have set textfield as graphic of cell . whenever i change the text of any row i want to get thats change text and that particular row number and column nuber. so i have added listener to get that change text but i cant get that particular row number at that time. – Ifran May 04 '13 at 11:33
  • You have to put the complete description of your problem, and what have tried , to get relevant answers. – Salah Eddine Taouririt May 04 '13 at 11:35