java - Auto Slideshow in JavaFX Pagination -


i've been using javafx lately, beginner, , have been impressed. @ moment i'm stuck trying set pagination slideshow automatically move slideshow forward every 5 seconds (and first slide continue when last slide reached). can 1 steer me in right direction here?

    @fxml public void slideshow(actionevent event) {     // todo auto-generated method stub     string[] photos = { "housestark.jpg", "housefrey.jpg", "housebar.jpg",             "housebolton.jpg", "housegreyjoy.jpg", "houseaaryn.jpg",             "houselannis.jpg", "housemart.jpg", "housereed.jpg",             "housetully.jpg", "housetyrel.jpg", };     pagination p = new pagination(photos.length);     p.setpagefactory((integer pageindex) -> {         return new imageview(getclass().getresource(photos[pageindex])                 .toexternalform());     });      stage stage = new stage();     stage.setscene(new scene(p));     stage.setx(1250);     stage.sety(10);     stage.settitle("slideshow");     stage.setresizable(false);     stage.show(); } 

this code far! appreciate give?

it's pretty easy. have create timer runs every 5 seconds, , when runs move page index.

public class extends application {      public static void main(string[] args) {         launch(args);     }      @override     public void start(stage stage) {         pagination p = new pagination(10);          timeline fivesecondswonder = new timeline(new keyframe(duration.seconds(5), event -> {             int pos = (p.getcurrentpageindex()+1) % p.getpagecount();             p.setcurrentpageindex(pos);         }));         fivesecondswonder.setcyclecount(timeline.indefinite);         fivesecondswonder.play();          stage.setscene(new scene(p));         stage.show();     } } 

the 5 second wonder came here: javafx periodic background task


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -