I'm having a problem setting the x and y position of an ImageView in a JavaFX Pane. It is a looping code, and the first time the method is called, it points to the img object in the specific coordinates (last two lines), but from the second time, Java ignores that position. Here is the code:
private void embarque_para_vagao(){
int dif, aux, dif2;
if(Integer.parseInt(nome) <= 4 ){
aux = Integer.parseInt(nome);
dif = -40;
dif2 = 5 - Integer.parseInt(nome);
}
else{
aux = Integer.parseInt(nome)-4;
dif = 75;
dif2 = Integer.parseInt(nome)-1;
}
PathTransition entra_fila = new PathTransition();
entra_fila.setNode(img);
entra_fila.setDuration( Duration.seconds( TempoEmbarque ) );
Polyline line = new Polyline(
60+42*(aux+dif2), -210-42*3,
60+42*(aux+dif2-vagao.CadeirasOcupadas), -210-42*3,
60+42*(aux+dif2-vagao.CadeirasOcupadas), -210-42*4
);
entra_fila.setPath(line);
entra_fila.play();
while(entra_fila.getStatus() == Animation.Status.RUNNING){
System.out.println(entra_fila.getStatus());
}
Platform.runLater(() -> {
ancVagao.getChildren().add(img);
});
img.setX(-188);
img.setY(-70);
}