In JavaFX, I have a TextField Called "randomIntegerField" I need to auto populate this textfield JavaFX with an integer value returned by a method when i clik on a button.
Here is the method which return the int Value
private int randomNum(){
Random random = new Random();
int integerIntered = Integer.parseInt(numberField.getText());
return random.nextInt(integerIntered - 0 + 1) + 0;
}
Here is the Button
bntGo.setText("Go");
bntGo.setOnAction(e -> {
randomIntegerField = String.valueOf(randomNum()); // The error i get is String can not converted into TextField.
});
Help me please
You need to set the text property of randomIntegerField
(which I assume is a TextField
), for example...
bntGo.setOnAction(e -> {
randomIntegerField.setText(String.valueOf(randomNum()));
});