title: Trying to set Label (Javafx) keep getting "Cannot invoke "javafx.scene.control.Label.setText(String)"" error message
body: <p>Uppdate: tried changing the Label field from static to just public. Im still getting the same error.</p>
  <p>Im doing my very first Java application and im trying to set some labels to certain price values. (The project is sort of a webshop). But when i use the command label.setText(String) i keep getting the same error.</p>
  <pre><code>Caused by: java.lang.NullPointerException: Cannot invoke &quot;javafx.scene.control.Label.setText(String)&quot; because &quot;project.AppController.labelProdukt1&quot; is null
  </code></pre>
  <p>The controller code is:</p>
  <pre><code>public class AppController {
  @FXML private Button VelgKnapp1;
  @FXML private TextArea antall;
  @FXML public static Label labelProdukt1;
  private Stage stage;
  private Parent root;
  private Scene scene;
  
  //private List&lt;Item&gt; liste = new ArrayList&lt;&gt;();
  
  public void setLabels() {
  Cart cart = new Cart();
  List&lt;Item&gt; liste = cart.getAvailableItems();
  System.out.println(liste);
  String price1 = String.valueOf(liste.get(0).getPrice()); 
  System.out.println(price1);
  System.out.println(labelProdukt1);
  labelProdukt1.setText(price1);
  
  } public void VelgProdukt1(ActionEvent event) throws IOException {   
  Parent root = FXMLLoader.load(getClass().getResource(&quot;Produkt.fxml&quot;));
  stage = (Stage)((Node)event.getSource()).getScene().getWindow();
  scene = new Scene(root);
  stage.setScene(scene);
  stage.show();
  setLabels();
  
  
  
  }
  </code></pre>
  <p>the idea here is that when you open the &quot;produkt&quot; scene it will also set the label in that scene to the price of that given item. I used the sysouts as sort of a guideline to see whether the error was because of formatting but when i try to print the price in the console it works perfectly. Im guessing there is some sort of mechanic in java/javafx that im missing but cant see to find the answer online.</p>
  <p>PS: if you need one of the fxml files for either the &quot;produkt&quot; or something just let med know.</p>
  <p>Any help is appreciated, thank you in advance!</p>