Answers for "javafx drag a stage"

1

how to make stage dragable in javafx

private double x = 0;
    private double y = 0;

    private void makeCanDrag()	//make sure this method is called at the start.
    {

        parent.setOnMousePressed(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                x = event.getSceneX();
                y = event.getSceneY();
            }
        });

        parent.setOnMouseDragged(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
                stage.setX(event.getSceneX() -
Posted by: Guest on April-18-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language