title: Cannot access element in superclass Controller using @FXML anotation
body: <p>I'm trying to set up a simple example for my program using JavaFX.
  What I want to have is a Controller with a main.fxml; then the main.fxml will have a TabbedPane as root, with 2 tabs (tab1.fxml and tab2.fxml), each with its controller (Tab1Controller and Tab2Controller).</p>
  
  <p>Now this might be the prolem, yet I don't see why it would be a problem:</p>
  
  <p><strong>Tab1Controller and Tab2Controller both extend Controller</strong>; because they share various fields which are manipulated, for example a bottom status bar which needs constant updates.</p>
  
  <p>So far I managed to have working all controllers and .fxml.</p>
  
  <p>When I try to set up the text of the label in the Controller from one of the subclasses it just points to null, yet the label is initialised in the gui with its default text..
  Compiles correctly and lblController seems to be correctly linked to its fx:id in main.fxml.</p>
  
  <p>Any help/links are much appreciated.</p>
  
  <p>I've been looking at various posts but the only one getting close to what I need it this one:
  <a href="https://stackoverflow.com/questions/32098047/javafx-8-controllers-inheritance">JavaFX 8, controllers inheritance</a></p>
  
  <p>Main:</p>
  
  <pre><code>package sample;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          Parent root = FXMLLoader.load(getClass().getResource("../view/main.fxml"));
          primaryStage.setTitle("Hello World");
          primaryStage.setScene(new Scene(root, 600, 700));
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p>Main controller:</p>
  
  <pre><code>package sample;
  
  import javafx.fxml.FXML;
  import javafx.scene.control.Label;
  
  public class Controller {
      @FXML
      public Label lblController;
  
      public Controller() {
          System.out.println("CONTROLLER MAIN - CONSTRUCTOR");
      }
  
      @FXML
      public void initialize() {
          System.out.println("CONTROLLER MAIN - INITIALIZER");
      }
  
      protected void setSts(String sts) {
          lblController.setText(sts);
      }
  }
  </code></pre>
  
  <p>main.fxml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Label?&gt;
  &lt;?import javafx.scene.control.Tab?&gt;
  &lt;?import javafx.scene.control.TabPane?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;AnchorPane xmlns:fx="http://javafx.com/fxml/1"
              xmlns="http://javafx.com/javafx/8.0.60"
              fx:controller="sample.Controller"&gt;
      &lt;BorderPane&gt;
          &lt;center&gt;
              &lt;TabPane tabClosingPolicy="UNAVAILABLE"&gt;
                  &lt;Tab text="Tab 1"&gt;
                      &lt;AnchorPane&gt;
                          &lt;!--FOR fx:id HAS TO HAVE THE SAME NAME BUT IN LOWER CASE AS THE .fxml--&gt;
                          &lt;fx:include fx:id="tab1" source="tab/tab1.fxml"/&gt;
                      &lt;/AnchorPane&gt;
                  &lt;/Tab&gt;
                  &lt;Tab text="Tab 2"&gt;
                      &lt;AnchorPane&gt;
                          &lt;fx:include fx:id="tab2" source="tab/tab2.fxml"/&gt;
                      &lt;/AnchorPane&gt;
                  &lt;/Tab&gt;
              &lt;/TabPane&gt;
          &lt;/center&gt;
          &lt;bottom&gt;
              &lt;AnchorPane&gt;
                  &lt;Label fx:id="lblController" text="Controller Test"/&gt;
              &lt;/AnchorPane&gt;
          &lt;/bottom&gt;
      &lt;/BorderPane&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>Tab1Controller</p>
  
  <pre><code>package sample.ctrTab;
  
  import javafx.fxml.FXML;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.control.TextField;
  import sample.Controller;
  
  
  public class Tab1Controller extends Controller {
      @FXML
      Label lbl1;
      @FXML
      TextField txt1;
      @FXML
      Button btn1Save, btn1Load;
  
      public Tab1Controller() {
          super();
          System.out.println("CONTROLLER TAB 1 - CONSTRUCTOR");
      }
  
      @FXML
      void btn1Save() {
          System.out.println("CONTROLLER TAB 1 - SAVE CLICK");
  //        lblController.setText("ANYTHING"); //NULL POINTER HERE
  //        setSts(txt1.getText()); //OR HERE
      }
  
      @FXML
      void btn1Load() {
          System.out.println("CONTROLLER TAB 1 - LOAD CLICK");
      }
  
      protected void setSts(String sts) {
          super.setSts(sts);
      }
  }
  </code></pre>
  
  <p>tab1.fxml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.Label?&gt;
  &lt;?import javafx.scene.control.TextField?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  &lt;AnchorPane xmlns:fx="http://javafx.com/fxml/1"
              xmlns="http://javafx.com/javafx/8.0.60" fx:controller="sample.ctrTab.Tab1Controller"&gt;
      &lt;children&gt;
          &lt;Label fx:id="lbl1" layoutX="100" layoutY="50" text="Def tab 1"/&gt;
          &lt;TextField fx:id="txt1" layoutX="100" layoutY="70"/&gt;
          &lt;Button fx:id="btn1Save" onAction="#btn1Save" layoutX="100" layoutY="140" mnemonicParsing="false"
                  text="Save text"/&gt;
          &lt;Button fx:id="btn1Load" onAction="#btn1Load" layoutX="200.0" layoutY="140" mnemonicParsing="false"
                  text="Send to tab 2"/&gt;
      &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>