I am receiving a null pointer exception and I am not sure why. I have this function that is called when a button is pressed:
@FXML
private void handlePlayButton(ActionEvent e) {
for(Node child:getCenterPaneUndirectedNonWeightedGraph().getChildren()) {
if(child instanceof StackPane) {
StackPane vertex = (StackPane) child;
System.out.println(vertex == null);
bfs.fillVertexTransition(vertex);
}
}
}
My print statement 'System.out.println(vertex == null);' prints false.
I get the null pointer exception at the line:
bfs.fillVertexTransition(vertex);
The method 'fillVertexTransition' is defined by:
public void fillVertexTransition(StackPane vertex) {
Circle circle = (Circle) vertex.getChildren().get(0);
FillTransition ft = new FillTransition(Duration.millis(3000), circle, Color.RED, Color.BLUE);
ft.play();
}
In my application the StackPanes are circles with a label on top of the circle.
Any way I can fix this?
Thank you.