title: Explicitly positioning nodes in JavaFX
body: <p>When I have clicked a button, it changes its position.  </p>
  
  <p>But when I move the mouse, the button comes back to the center of the scene, why?</p>
  
  <p>I have the following code:</p>
  
  <pre><code>public class HolaMundo extends Application {
  
      Button btn;
      Scene scene;
  
      @Override
      public void start(Stage primaryStage) {
          btn = new Button();
          btn.setText("Hola Mundo");
  
          StackPane root = new StackPane();
          root.getChildren().add(btn);
  
          scene = new Scene(root, 300, 250);
  
          primaryStage.setTitle("Hello World!");
          primaryStage.setScene(scene);
          primaryStage.show();
  
          scene.setOnMouseMoved(new EventHandler&lt;MouseEvent&gt;(){
  
              @Override
              public void handle(MouseEvent t) {
                   btn.setText(String.valueOf(t.getX() ));
              }
          });
  
          btn.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
  
              @Override
              public void handle(ActionEvent event) {
                  btn.setLayoutX(Math.random() * (300 - btn.getWidth()));
                  btn.setLayoutY(Math.random() * (250 - btn.getHeight())); 
              }
          });
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>