title: Why doesn't my fxml controller class move my button?
body: <p>I have 3 classes with which I'm currently working: ButtonMove.java, MainController.java, and Main.fxml. I've been experimenting with SceneBuilder to create user interfaces and wanted to add motion to an object. I've tried getting this button to move, but to no avail. The stage launches and I see the button, but it remains motionless. </p>
  
  <pre><code>package TestClasses;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class ButtonMove extends Application
  {
  
      @Override
      public void start(Stage stage) throws Exception {
          // TODO Auto-generated method stub
          Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
  
          Scene scene = new Scene(root);
          stage.setScene(scene);
          stage.show();
      }
  
  
      public static void main(String[] args) {
          launch(args);
  
      }
  
  
  }
  </code></pre>
  
  <p>The above class, ButtonMove.java, just loads the fxml file, Main.fxml, and launches the stage. Below is the Main.fxml controller file, which for some reason keeps telling me that javafx.fxml.FXML is never used.</p>
  
  <pre><code>package TestClasses;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  
  import javafx.animation.TranslateTransition;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.Button;
  import javafx.util.Duration;
  
  public class MainController implements Initializable
  {
  
      private Button button;
      @Override
      public void initialize(URL location, ResourceBundle resources) {
          // TODO Auto-generated method stub
          TranslateTransition transition = new TranslateTransition();
          transition.setDuration(Duration.seconds(4));
          transition.setNode(button);
          transition.setToY(-200);
          transition.play();
      }
  
  }
  </code></pre>
  
  <p>And this is just the fxml file generated by SceneBuilder.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  &lt;?import javafx.scene.layout.StackPane?&gt;
  
  &lt;StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"&gt;
     &lt;children&gt;
        &lt;AnchorPane prefHeight="200.0" prefWidth="200.0"&gt;
           &lt;children&gt;
              &lt;Button id="button" layoutX="274.0" layoutY="310.0" mnemonicParsing="false" text="CLICK" /&gt;
           &lt;/children&gt;
        &lt;/AnchorPane&gt;
     &lt;/children&gt;
  &lt;/StackPane&gt;
  </code></pre>