I am trying to print the input from a user in a TextArea to the console.
//controller
private void btnClick(ActionEvent event) {
System.out.println(input.getText());
}
//fxml
...
<left>
<Button id="booton" fx:id="booton" mnemonicParsing="false" onAction="#btnClick" text="Button" BorderPane.alignment="CENTER" />
</left>
<right>
<TextArea id="input" prefHeight="200.0" prefWidth="200.0" promptText="give me input" BorderPane.alignment="CENTER" />
</right>
</BorderPane>
It gives me this error when running along with alot more:
Caused by: java.lang.NullPointerException: Cannot invoke "javafx.scene.control.TextArea.getText()" because "this.input" is null at sample.Controller.btnClick(Controller.java:31)