I'm supposed to make a program that presents a simple empty text box that allows the user to enter a value that will be used to alter the radius of a circle that is drawn in the background. Here is my source code so far:
import javafx.event.ActionEvent;
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;
import javafx.scene.shape.*;
import javafx.scene.paint.Color;
public class FahrenheitPane extends GridPane {
private Label result;
private TextField radius;
public FahrenheitPane() {
Font font = new Font(18);
Circle circle = new Circle();
circle.setRadius(50.0f);
circle.setFill(Color.BLACK);
setAlignment(Pos.CENTER);
radius = new TextField();
radius.setFont(font);
radius.setPrefWidth(150);
radius.setAlignment(Pos.CENTER);
radius.setOnAction(this::processReturn);
setAlignment(Pos.CENTER);
setStyle("-fx-background-color: purple");
add(radius, 1, 0);
add(circle, 0, 0);
}
public void processReturn(ActionEvent event) {
int radiusTemp = Integer.parseInt(radius.getText());
return rediusTemp;
}
}
I'm trying to associate the input value with a variable so then I can use it the line that specifies the radius of the circle so that it may change whenever the return key is pressed.
Please point me in the right direction, but do not try to solve it for me. I appreciate the gesture, but it is not the type of help I need. Thank you!