Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX graphic bug with progressBar and Slider

I am writing a small application (Audio player with features); I use slider and progress bar to show a progress of current track. But When track is changed a progressBar and Slider take old position (with random chance);

You can see it on progress of song

Here is a code of fxml:

<StackPane layoutY="64.0" prefHeight="20.0" prefWidth="492.0" AnchorPane.leftAnchor="26.0"     AnchorPane.rightAnchor="24.0">
  <children>
<ProgressBar id="progress" fx:id="progressBar" cache="true" cacheHint="QUALITY" disable="true" maxHeight="-1.0" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" opacity="1.0" prefHeight="9.0" prefWidth="-1.0" progress="0.0" />
<Slider fx:id="progressSlider" disable="false" opacity="1.0" value="0.0" />
  </children>
</StackPane>

when new track overrides the old graphic, it gone.

Can anybody help me?

like image 254
Vetalll Avatar asked Oct 22 '22 19:10

Vetalll


1 Answers

I solved this issue. I had to call new JavaFX thread from JavaFX thread;

Platform.runLater(new Runnable(){......});
like image 193
Vetalll Avatar answered Oct 27 '22 18:10

Vetalll