下面的代码显示了我的顺序转换函数的一部分,我希望使用pslideshow.pause()让用户暂停幻灯片,并继续播放幻灯片。
但是我意识到,一旦我使用pslideshow.play(),当我点击我创建的显示幻灯片的窗格时,pslideshow的状态会立即变为stopped。
我应该怎么做才能让用户暂停并再次播放我的顺序转换?提前谢谢!
public void start(){
for (Label slide : LabelSlides) {
SequentialTransition sequentialTransition = new SequentialTransition();
FadeTransition fadeIn = getFadeTransition(slide, 0.0, 1.0, 2000);
PauseTransition stayOn = new PauseTransition(Duration.millis(2000));
FadeTransition fadeOut = getFadeTransition(slide, 1.0, 0.0, 2000);
sequentialTransition.getChildren().addAll(fadeIn, stayOn, fadeOut);
slide.setOpacity(0);
this.root.setStyle("-fx-background-color: Black");
this.root.getChildren().add(slide);
Pslideshow.getChildren().add(sequentialTransition);
}
Pslideshow.play();
}
@FXML
public void PlaySlide(ActionEvent event) throws IOException
{ Node node=(Node) event.getSource();
Stage stage=(Stage) node.getScene().getWindow();
Stage newStage = new Stage();
newStage.setWidth(stage.getWidth());
newStage.setHeight(stage.getHeight());
Scene_3Controller simpleSlideShow = new Scene_3Controller();
Scene scene = new Scene(simpleSlideShow.getRoot());
MediaP.play();
simpleSlideShow.start();
scene.setOnMouseClicked(new ClickHandler());
newStage.setScene(scene);
newStage.show();
}
1条答案
按热度按时间xlpyo6sf1#
代码是从我创建的sequentialtransitionstatus gist复制的,它解释了sequentialtransition如何改变不同的状态,即running、paused、stopped。