At the moment I have a list with images which get displayed for a certain amount of time with a timeline. However I want that after each there is a small pause where no image is displayed? Is there a way to achieve that behavior?
Here is the Code I use so far:
ImageView imView = new ImageView();
Duration timeBetweenImages = Duration.millis(10000);
Timeline timeline = new Timeline();
for (int i = 0; i < imageList.size(); i++) {
Image image = imageList.get(i);
Duration frameTime = timeBetweenImages.multiply(i);
KeyFrame frame = new KeyFrame(frameTime, e -> imView.setImage(image));
timeline.getKeyFrames().add(frame);
}
timeline.play();
As for now each picture is displayed 10 seconds. I want that after the each 10 seconds there is a 1 second pause where no image is displayed.
ImageView imView = new ImageView();
Duration timeBetweenImages = Duration.seconds(11);
Duration pauseTime = Duration.seconds(1);
Timeline timeline = new Timeline();
for (int i = 0; i < imageList.size(); i++) {
Image image = imageList.get(i);
Duration frameTime = timeBetweenImages.multiply(i);
KeyFrame frame = new KeyFrame(frameTime, e -> imView.setImage(image));
timeline.getKeyFrames().add(frame);
Duration pauseFrameTime = timeBetweenImages.multiply(i+1).subtract(pauseTime);
KeyFrame pauseFrame = new KeyFrame(pauseFrameTime, e -> imView.setImage(null));
timeline.getKeyFrames().add(pauseFrame);
}
timeline.play();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.