title: How to get GridPane Row and Column IDs on Mouse Entered in each cell of Grid in JavaFX?
body: <p>I am trying out JFX Drag and Drop feature in my application (later connecting the objects in a sequence). I could not find any easy way to drag and drop my ImageView/Button at suitable position in my pane, hence I am planning to apply use of GridPane. The GridPane would be a large canvas with more than (50x50) cells.</p>
  
  <p>If I specify in my code that I need to drag and drop by ImageView at, let's say, (2,2) cell, I am able to do it. But, I need to give that access to my user. User could move the pointer in grid and would drop the ImageView/Button at any cell in the grid. </p>
  
  <p>Now, I would like to find out rowID and columnID of the cell on mouse entered in a particular cell of the GridPane.</p>
  
  <p>I am handling mouse event in my Controller as follows:</p>
  
  <pre><code>package sample;
  
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.input.*;
  import javafx.scene.layout.GridPane;
  import javafx.scene.paint.Color;
  import javafx.stage.Stage;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  
  public class Controller implements Initializable{
  Stage stage;
  
  @FXML
  private GridPane gridPane;
  
  public void setStage(Stage primaryStage){
      stage = primaryStage;
  }
  
  @Override
  public void initialize(URL location, ResourceBundle resources) {
      System.out.println("initialize");
  }
  
  
  @FXML
  private void handleMouseEntered(MouseEvent event){
      System.out.println("MouseEntered");
  }
  
  }
  </code></pre>
  
  <p>When enters in the gridpane, I get "MouseEntered" only once. Besides, I am not able to get any RowID and ColumnID, hence, I have not written any function in the function.</p>
  
  <p>My interface looks like following:
  <img src="https://i.stack.imgur.com/UxvGZ.png" alt="enter image description here"></p>
  
  <p>I would like to know two things:</p>
  
  <p>[] How to detect mouse entry in each cell of the gridpane?</p>
  
  <p>[] How to find out row and column IDs of the particular cell?</p>
  
  <p>Thanks in advance.</p>