JavaFX TableView/Column Null pointer exception
<p>I am having trouble with Null pointers when trying to initiate Table population.
I have my object from class called <code>Komponenta</code> which data I put in <code>ObservableList</code> and then try to show it in a <code>TableView</code>. I've tried this time to work with multiple fxml screens and for some reason it doesn't work with more than 1 <code>.fxml</code>. <code>test</code> is a method that I call when a button is pressed on <code>main.fxml</code> so it loads a new one.</p>

<p>MainController.java</p>

<pre><code>public ObservableList&lt;Komponenta&gt; komponente = FXCollections.observableArrayList(new Komponenta("Neki Tip", "Neki Proizvodac","Neki opis", 5));
@FXML
private TableView&lt;Komponenta&gt; Tablica;
@FXML
private TableColumn&lt;Komponenta,String&gt; Tip;
@FXML
private TableColumn&lt;Komponenta,String&gt; Proizvodac;
@FXML
private TableColumn&lt;Komponenta,String&gt; Karakteristika;
@FXML
private TableColumn&lt;Komponenta,Integer&gt; Komada;
@FXML
private void test(ActionEvent event) throws IOException{
    Node node=(Node) event.getSource();
    Stage stage = (Stage) node.getScene().getWindow();
    Parent root = (Pane)FXMLLoader.load(getClass().getResource("ElKomponenta.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();       
}
@FXML
private void initialize() throws Exception  {
    System.out.println(komponente.get(0).getKomada());
    Tip.setCellValueFactory(new PropertyValueFactory&lt;Komponenta, String&gt;("tip"));
    Proizvodac.setCellValueFactory(new PropertyValueFactory&lt;Komponenta, String&gt;("proizvodac"));
    Karakteristika.setCellValueFactory(new PropertyValueFactory&lt;Komponenta, String&gt;("karakteristika"));
    Komada.setCellValueFactory(new PropertyValueFactory&lt;Komponenta, Integer&gt;("komada"));
    Tablica.setItems(komponente);
}
</code></pre>

<p>ElKomponenta.fxml</p>

<pre class="lang-xml prettyprint-override"><code>&lt;TableView fx:id="Tablica" prefHeight="603.0" prefWidth="889.0"&gt;
  &lt;columns&gt;
    &lt;TableColumn fx:id="Tip" prefWidth="177.0" text="Tip" /&gt;
    &lt;TableColumn fx:id="Proizvodac" minWidth="0.0" prefWidth="207.0" text="Proizvođač" /&gt;
      &lt;TableColumn fx:id="Karakteristika" prefWidth="326.0" text="Karakteristike" /&gt;
      &lt;TableColumn fx:id="Komada" minWidth="0.0" prefWidth="178.0" text="Komada" /&gt;
  &lt;/columns&gt;
&lt;/TableView&gt;
</code></pre>

<p>Error:</p>

<pre><code>Caused by: java.lang.NullPointerException
at application.MainController.initialize(MainController.java:62)
... 27 more
</code></pre>

<p>Which is the line that first starts to <code>setCellValueFactory</code>.</p>

<p>Also if needed, Komponenta.java</p>

<pre><code>public class Komponenta {

    private String proizvodac;
    private String tip;
    private String karakteristika;
    private Integer komada;

    public Komponenta(String a, String b, String c, Integer d){
        this.tip = a;
        this.proizvodac = b;
        this.karakteristika = c;
        this.komada = d;
    }

    public String getProizvodac() {
        return proizvodac;
    }

    public void setProizvodac(String proizvodac) {
        this.proizvodac = proizvodac;
    }

    public String getTip() {
        return tip;
    }

    public void setTip(String tip) {
        this.tip = tip;
    }

    public String getKarakteristika() {
        return karakteristika;
    }

    public void setKarakteristika(String karakteristika) {
        this.karakteristika = karakteristika;
    }

    public Integer getKomada() {
        return komada;
    }

    public void setKomada(Integer komada) {
        this.komada = komada;
    }

}
</code></pre>