- Thread Author
- #1
I have my UI built and I am trying to figure out how to pass variables from UI via the controller to other classes. (Ex. I am trying to get a food string from a TextField and use it in my withdrawItems class). My initial approach was to set a global String food; variable in the controller then when the start button is pressed it assigns the food variable from a TextField foodChoice.getText();. Then I pass an instance of the bot main class to my other classes which call bot.controller.getFood() which returns the global food variable in the Controller but this returns null.
I am aware the proper method has something to do with Platform.invokeLater(); but I am seriously confused on how this works and I have tried doing this in many different places within the controller and main class the following way:
botPlatform.invokeLater(new Runnable() {
@Override
public void run() {
String food2 = foodChoice.getText();
setFood(food2);
}
});
Any suggestions or tips on how to accomplish this would be much appreciated.
I am aware the proper method has something to do with Platform.invokeLater(); but I am seriously confused on how this works and I have tried doing this in many different places within the controller and main class the following way:
botPlatform.invokeLater(new Runnable() {
@Override
public void run() {
String food2 = foodChoice.getText();
setFood(food2);
}
});
Any suggestions or tips on how to accomplish this would be much appreciated.