Question

I want to fire an event while dragging stage. I found a lot of examples about undecorated stage dragging which has set event (MouseEvent) on pane but not on stage. Is there any way through which I can solve this problem?

Was it helpful?

Solution

Does it work just to observe the x and y properties of the stage?

i.e.:

final Stage stage ;
// ...

ChangeListener<Number> stageMoveListener = new ChangeListener<Number>() {
    @Override
    public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number new Value) {
        System.out.println("Stage moved to "+stage.getX()+", "+stage.getY());
    }
});
stage.xProperty().addListener(stageMoveListener);
stage.yProperty().addListener(stageMoveListener);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top