How to get to assign a variable from another class in JavaFX?

Welcome!
Started to learn Java and JavaFX respectively.
A simple example will show the problem surfaced.

There is a standard Controller class created by Java FX and class ChatBot, for example.

Controller:
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;
public class Controller {
 private ChatBot chatBot = new ChatBot();
 @FXML Button enterButton;
 @FXML TextField answerTextField;
 @FXML Label botAnswer;
 int counter = 0;
 public void button1Click(ActionEvent actionEvent) {
chatBot.setAnswer("[][][]");
botAnswer.setText(chatBot.getChatting(counter));
counter++;
}
}


ChatBot:

public class ChatBot {
 String answer;

 private String string1 = "Hello!\Ni m intellectual system.\nMy name is... is... my name...\nOh... I forgive it.\n" +
 "Starting self-test.\nCore damaged.\nPlease, initialize the variable again.\nMy name?";
 private String string2 = "Ok my name is" + answer + ". Please, type the date of my creation.";
 private String string3 = "My creation date" + answer + "? I'm very young. Thank you. Can you remind me your name?";
 private String string4 = "What a great name you have," + answer + "!\nLet me guess your age.\nEnter remainders of divining your age by 3, 5 and 7.";

 String[] chatting = {string1, string2, string3, string4};


 public String getChatting(int counter) {
 return chatting[counter];
}

 public void setAnswer(String answer) {
 this.answer = answer;
 }


When you click on a Button Label displays the text that the idea has from the textField text answer.
What am I doing wrong?
April 3rd 20 at 17:37
0 answer

Find more questions by tags JavaJavaFX