0

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.

Frank
  • 521
  • 7
  • 19
  • You probably need to post some code to show what you're doing. If you're registering the mouse handlers with the drag panes, then you already have a reference to the relevant drag pane available. – James_D Feb 22 '15 at 02:05
  • Coming from a C background (that's without the ++) I assigned the same handler for all panes in expectation of using a switch() to handle the different panes, but maybe eight different handlers is a better way to go. Thanks for the hint. – Frank Feb 23 '15 at 07:22
  • I (almost) always prefer to use a different handler for each node, rather than accessing the event source. – James_D Feb 23 '15 at 16:04

1 Answers1

0

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!

Frank
  • 521
  • 7
  • 19