Search code examples
resizejavafx-8handles

JavaFX8 node resize handles


I have a StackPane to which I add child panes. Each child has MouseEvent handlers to drag it around the StackPane. Works fine. Then I also want to be able to resize that pane. So I added 8 small 'drag' panes to the child in the appropriate places each with its own clicked/drag handlers.

The problem: once a 'drag' pane mouse event fires, I need to set an anchor point for the parent pane. This anchor point will depend on which 'drag' pane was clicked. How do I identify which pane was clicked in the handler? I suspect I am missing something very obvious, but I cannot see it (Google provides no answers).

I tried using the hashcode, but no luck.


Solution

  • Finally realised what the solution was after Googling a different issue. I had tried event.getSource(), but couldn't relate the returned object to my pane. The solution is simply to cast it (Panel)event.getSource() it and then it's all go! Talking about dim!