title: JavaFX functions do not work even though there are no errors
body: <p>I'm following a tutorial loosely by thenewboston and I'm running into a bit of a roadblock. To my understanding the ID in the .JFXM file is equivalent to a variable in the controller class. The onAction command is a reference to a function in the controller class.</p>
  
  <p>The tutorial link: <a href="https://www.youtube.com/watch?v=LMdjhuYSrqg" rel="nofollow noreferrer">https://www.youtube.com/watch?v=LMdjhuYSrqg</a></p>
  
  <p>What I don't understand:</p>
  
  <ol>
  <li><p>Why I need to initialize the variable <code>public Button loginBtn = new Button();</code> when in the tutorial he does not. </p></li>
  <li><p>Why does setText do nothing <code>loginBtn.setText("aahh!");</code></p></li>
  <li><p>If I wanted to get text from a field, I would use <code>System.out.println(FXuserLoginName.getText());</code> Which results in an error if the variable is not initialized. If It IS initialized, nothing happens. </p></li>
  </ol>
  
  <p>Any help is appreciated. Below is the code:</p>
  
  <pre><code>package application;
  
  import javafx.application.Application;
  import javafx.stage.Stage;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.PasswordField;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.BorderPane;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  
  public class Jfx extends Application {
      public Button loginBtn = new Button();
      TextField FXuserLoginName;
      PasswordField userLoginPassword;
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          try {
  
              Parent root = FXMLLoader.load(getClass().getResource("Login.fxml"));    
              Scene scene = new Scene(root,208,208);
              scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
              primaryStage.setTitle("Odin");
              primaryStage.setScene(scene);
              primaryStage.show();
          } catch(Exception e) {
              e.printStackTrace();
          }
      }
  
      public void ActionloginButton() {//logs into database, loginButton is connected to Login.fxml there #loginButton is present
          loginBtn.setText("aahh!");
          System.out.println("Login button..");
          //System.out.println(FXuserLoginName.getText());
          System.out.println("Got text");
      }
  }
  </code></pre>
  
  <p>And here is my Controller</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.PasswordField?&gt;
  &lt;?import javafx.scene.control.TextField?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  
  &lt;AnchorPane prefHeight="150.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Jfx"&gt;
     &lt;children&gt;
        &lt;TextField id="FXuserLoginName" layoutX="29.0" layoutY="37.0" promptText="Username" /&gt;
        &lt;PasswordField id="userLoginPassword" layoutX="29.0" layoutY="76.0" maxHeight="-Infinity" maxWidth="-Infinity" promptText="Password" /&gt;
        &lt;Button id="loginBtn" layoutX="81.0" layoutY="113.0" mnemonicParsing="false" text="Login" onAction="#ActionloginButton"/&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>