JavaFX Access Function in Controller Class from Main
<p>This has me banging my head against the wall!!!! Hoping someone can point me in the righr direction.  I am sure I am doing something COMPLETELY STUPID AND DUMB.  I have searched and searched, but cant seem to find out why this is NOT working!!  (Using JDK8.x with Scenebuilder on IntelliJ IDE 15.x).  I am trying to display data on the GUI, but want access to have this data programatically send to it from other classes/methods....here is a simple concept I am trying to make work before working on my larger project:</p>

<pre><code>Main Class:

package sample;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

Controller myController = new Controller();

@Override
public void start(Stage primaryStage) throws Exception{
    Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("Hello World");
    primaryStage.setScene(new Scene(root, 345, 200));
    primaryStage.show();
    myController.pushBtn();
}

public static void main(String[] args) {
    launch(args);
   }
  }
</code></pre>

<p>My simple GUI, defined in FXML with Scenebuilder Controller class:</p>

<pre><code>package sample;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;

public class Controller {

@FXML // ResourceBundle that was given to the FXMLLoader
private ResourceBundle resources;

@FXML // URL location of the FXML file that was given to the FXMLLoader
private URL location;

@FXML // fx:id="txtBox"
private TextField txtBox; // Value injected by FXMLLoader

@FXML // fx:id="myButton"
private Button myButton; // Value injected by FXMLLoader

@FXML // This method is called by the FXMLLoader when initialization is   complete
void initialize() {
    assert txtBox != null : "fx:id=\"txtBox\" was not injected: check your   FXML file 'sample.fxml'.";
    assert myButton != null : "fx:id=\"myButton\" was not injected: check     our FXML file 'sample.fxml'.";
}
@FXML
private void pressBtn(ActionEvent event){
    txtBox.setText("Btn was pushed...");
}

@FXML
public void pushBtn(){
    txtBox.appendText("Sample from Main");
}

}
</code></pre>

<p>..and Finaly my very simple FXML file, along with the ID's and event handler tags:</p>

<pre><code>&lt;GridPane alignment="center" hgap="10" vgap="10"      xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.65"       fx:controller="sample.Controller"&gt;
  &lt;columnConstraints&gt;
  &lt;ColumnConstraints /&gt;
  &lt;/columnConstraints&gt;
  &lt;rowConstraints&gt;
    &lt;RowConstraints /&gt;
 &lt;/rowConstraints&gt;
 &lt;children&gt;
   &lt;Pane prefHeight="200.0" prefWidth="345.0" style="-fx-background-color:  GRAY;"&gt;
       &lt;children&gt;
         &lt;TextField fx:id="txtBox" layoutX="63.0" layoutY="28.0"     prefHeight="53.0" prefWidth="224.0" style="-fx-background-color: LIGHTGRAY;" /&gt;
          &lt;Button fx:id="myButton" layoutX="140.0" layoutY="100.0"  mnemonicParsing="false" onAction="#pressBtn" text="Button" /&gt;
       &lt;/children&gt;
      &lt;/Pane&gt;
  &lt;/children&gt;
 &lt;/GridPane&gt;
</code></pre>

<p>All I am trying to do, is to call a function which has been declared public on the controller class, and have that function place text in my txtBox, which has been defined with FXML as you can see.  I create an instance of that controller class in main, and then use that instance to access this method.  All I have been reading and searching here, point that this is the right way to do it.  However, this NEVER works, and all I get is an error as such:</p>

<pre><code>Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in   Application start method
  at      com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at    com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImp    l.java:182)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at sample.Controller.pushBtn(Controller.java:43)
at sample.Main.start(Main.java:20)
at    com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherIm    pl.java:863)
at     com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at    com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at    com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at     com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at     com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more `
</code></pre>

<p>What the heck am I missing?  Is there another way to call this, am I not initializing something?  REALLY do appreciate any feedback!!!</p>