I am making a stopwatch program and I want to set a photo for rotation. The problem is, is that I dont know how to call the photo in the controller file. It just tells me that it cannot find symbol.
Heres the photo I want to call from my .fxml file
<ImageView fx:id="hand">
<image>
<Image url="@hand.png"/>
</image>
</ImageView>
And heres where I call it in my controller file, but I get an error.
@FXML
private void updateStopwatch(){
elapsedTime++;
Integer rotation = elapsedTime * 6;
hand.setRotate(rotation);
}
Thanks for the help in advance. The error I get is the following :
hand.setRotate(rotation);
^^^^
Cannot find symbol hand
When you have given the fxml object you want to inject into your controller the correct property fx:id="hand"
you need to declare that id as a property in your controller class.
public class MyController {
@FXML private ImageView hand;
private void updateStopwatch(){
elapsedTime++;
Integer rotation = elapsedTime * 6;
hand.setRotate(rotation);
}
}
In your fxml file you must refer to the controller(MyController) by adding this attribute in root element:
fx:controller="some.package.MyController"
your fxml file may only refer to one controller.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments