JavaFX2 ChoiceBox populate with values
<p>I'v this kinda of question, but none of the suggested solutions helped.</p>

<p>I am using JavaFX 2.2, Java 6.</p>

<p>I have ChoiceBox defined in FXML:</p>

<pre><code>&lt;ChoiceBox fx:id="companyList" prefHeight="25.0" prefWidth="300.0" /&gt;
</code></pre>

<p>then I have reference to it in my "Main" class:</p>

<pre><code>@FXML
public ChoiceBox&lt;String&gt; companyList;
</code></pre>

<p>Inside "start" method I try to populate it with values like this</p>

<pre><code>companyList = new ChoiceBox&lt;String&gt;();
companyList.setItems(FXCollections.observableArrayList("One","Two","Three"));
</code></pre>

<p>But no values are added to list;
I'v tried in many different ways suggested in:
<a href="https://stackoverflow.com/questions/23067256/populate-choicebox-defined-in-fxml">Populate Choicebox defined in FXML</a>
<a href="https://stackoverflow.com/questions/15554715/how-do-i-populate-a-javafx-choicebox-with-data-from-the-database">How do I populate a JavaFX ChoiceBox with data from the Database?</a>
<a href="https://stackoverflow.com/questions/19691533/javafx-2-choicebox-with-custom-item">JavaFx 2 ChoiceBox with custom item</a></p>

<p>I don't get any compilation errors, but it just don't work, what I am doing wrong?</p>

<p>(PS I am new to Java)</p>

<h3>EDIT (SOURCE)</h3>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;?import javafx.geometry.*?&gt;
&lt;?import javafx.scene.control.*?&gt;
&lt;?import javafx.scene.layout.*?&gt;

&lt;GridPane focusTraversable="true" prefHeight="435.0" prefWidth="320.0" snapToPixel="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Main"&gt;
   &lt;Pane prefHeight="425.0" prefWidth="300.0" GridPane.columnIndex="1" GridPane.rowIndex="1"&gt;
      &lt;VBox&gt;
         &lt;VBox minHeight="50.0"&gt;
            &lt;Label prefHeight="25.0" text="Įmonė kuriai generuojamas išrašas" /&gt;
            &lt;ChoiceBox fx:id="companyList" prefHeight="25.0" prefWidth="300.0" /&gt;
             &lt;!-- other markup is irrelevant--&gt;
</code></pre>

<p>Main class:</p>

<pre><code>package sample;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;

public class Main extends Application {
    @FXML public ChoiceBox&lt;String&gt; companyList;

    @Override
    public void start(final Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("IST Billing Generator");
        Scene scence = new Scene(root);
        primaryStage.setScene(scence);

        companyList = new ChoiceBox&lt;String&gt;();
        companyList.setItems(FXCollections.observableArrayList("One","Two","Three"));

        this.primaryStage = primaryStage;
        primaryStage.show();
    }
    //other code is irrelevant too
}
</code></pre>