I have a ChangeListener
that when triggered, a findGPA()
method is called.
private void findGPA(){
GPA = gradeCre/sum;
decGPA = new BigDecimal(GPA);
decGPA = decGPA.setScale(2, RoundingMode.CEILING);
System.out.println("Your average GPA is: " + decGPA);
}
The BigDecimal
is initialized as follows:
private BigDecimal decGPA = BigDecimal.ZERO;
In the initialize()
method:
SubmitStageBorderPane.setBottom(AddStackCircle());
which calls:
private StackPane AddStackCircle(){
StackPane stackCircle = new StackPane();
StringProperty gpa = new SimpleStringProperty("");
gpa.bind(new SimpleStringProperty(decGPA.toString()));
Text avgGPA = createText("Your semester GPA is: " + gpa);
Circle resultCircle = createCircle(avgGPA);
stackCircle.getStyleClass().add("stackCircle");
stackCircle.getChildren().addAll(resultCircle, avgGPA);
return stackCircle;
}
private Circle createCircle(Text avgGPA){
Circle resultCircle = new Circle();
resultCircle.setFill(Color.GREEN);
resultCircle.setStroke(Color.GREY);
resultCircle.setStrokeWidth(3);
resultCircle.setRadius(getWidth(avgGPA) / 2 + 10);
return resultCircle;
}
private Text createText(String text){
Text avgGPA = new Text(text);
avgGPA.setBoundsType(TextBoundsType.VISUAL);
avgGPA.getStyleClass().add("avgGPA");
return avgGPA;
}
However, when i run it, it produces the following label text Your semester GPA is: StringProperty[bound, invalid]
, and it doesn't change even when the value of decGPA
changes.