title: How to place shape in random locations on pane?
body: <p>I am working on a final project and am making a game that has a dot that will randomly move around a window, and when it is clicked, the users score will increase. I am wondering how to move the dot around randomly every half second or so. Here is all the code I have so far, thanks!</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.stage.Popup;
  import javafx.stage.Stage;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.input.MouseEvent;
  import javafx.scene.layout.Pane;
  import javafx.scene.shape.Circle;
  import javafx.scene.shape.Line;
  import javafx.scene.text.Text;
  import java.util.Random;
  import java.util.Timer;
  import java.util.TimerTask;
  
  
  public class CatchTheDot extends Application{
  
  //create ball for game
  public static Circle dot;
  
  //create pane to run game
  public static Pane window;
  
  //create score counter
  int score = 0;
  
  //creat random
  Random r = new Random((21)+1);
  
  @Override
  public void start(Stage primaryStage) throws Exception {
  
      window.getChildren().addAll(dot);
  
      // create scene and place on pane
      Scene s = new Scene(window, 800, 800);
      primaryStage.setTitle("Catch The Dot");
      primaryStage.setScene(s);
      primaryStage.show();
  
      //move dot
      Timer timer = new Timer();
      timer.schedule(new TimerTask() 
          {
          @Override
          public void run(){
          window.getChildren().remove(dot);
          int randX = 1 + (int)(Math.random()*800);
          int randY = 1 + (int)(Math.random()*800);
          window.add(dot, randX, randY);
          }
          }, 0, 5000);        
  
  
      // create listener
      ActionEvent mouseClicked(ActionEvent event)
      {
          if(event.getSource()==dot)
          {
              score = score + 10;
              if(score == 50)
              {
                  popUp(primaryStage);
              }
          }
      }
  }
  
  public void popUp(final Stage primaryStage)
  {
      primaryStage.setTitle("You won!");
      final Popup popup = new Popup();
      popup.setX(300);
      popup.setY(200);
      Text t = new Text("You won! Nice job!");
      Text tt = new Text("Play again?");
      Button yes = new Button("yes");
      Button no = new Button("no");
      popup.getContent().addAll(t, tt, yes, no);
      yes.setOnAction(e -&gt; Yes());
      no.setOnAction(e -&gt; No());
  }
  
  public void Yes()
  {
      restartGame();
  }
  public void No()
  {
      System.exit(0);
  }
  public void restartGame()
  {
      score = 0;
  
  }
  public static void main(String[] args)
  {
      launch(args);
  }
  </code></pre>
  
  <p>}</p>