I'm trying to figure out where the mouse is, in terms of a GridPane's column and row. I know the mouse position, so I could presumably figure it out from that, if I knew each cell's width and height (which I don't see an easy way to figure out) but most of the code I've seen seems to presume the mouse is over a node inside the GridPane:
Node node = (Node) event.getTarget();
int row = GridPane.getRowIndex(node);
int column = GridPane.getColumnIndex(node);
But I actually don't have anything inside my GridPane, so I just get the whole GridPane. Now, I suppose I could add nodes for each of the cells, but this seems inefficient. (The idea is that the user is placing the nodes in a grid, so the grid starts out empty.)
Edit: To clarify, I basically want to do what SceneBuilder does when you place a GridPane down and then drag a component over it. The cell you're hovering over is highlighted and then (if you drop the component) it gets added to that cell. So I know it's possible (and also not outlandish as a concept).
Any thoughts?