Created
May 10, 2016 07:40
-
-
Save TheItachiUchiha/6be32dd48e52f7df3cdb9a15fd482ec0 to your computer and use it in GitHub Desktop.
Shows a SequentialTransition which can be paused and played
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.animation.FadeTransition; | |
import javafx.animation.PauseTransition; | |
import javafx.animation.SequentialTransition; | |
import javafx.application.Application; | |
import javafx.geometry.Pos; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Button; | |
import javafx.scene.control.Label; | |
import javafx.scene.layout.HBox; | |
import javafx.scene.layout.VBox; | |
import javafx.stage.Stage; | |
import javafx.util.Duration; | |
public class SequentialTransitionStatus extends Application { | |
@Override | |
public void start(Stage primaryStage) { | |
Label slide = new Label("slide"); | |
slide.setOpacity(0); | |
FadeTransition fadeIn = new FadeTransition(Duration.millis(2000), slide); | |
fadeIn.setFromValue(0); | |
fadeIn.setToValue(1); | |
PauseTransition stayOn = new PauseTransition(Duration.millis(1000)); | |
FadeTransition fadeOut = new FadeTransition(Duration.millis(2000), slide); | |
fadeOut.setFromValue(1); | |
fadeOut.setToValue(0); | |
SequentialTransition sequentialTransition = new SequentialTransition(); | |
sequentialTransition.getChildren().addAll(fadeIn, stayOn, fadeOut); | |
Label status = new Label(); | |
status.textProperty().bind(sequentialTransition.statusProperty().asString()); | |
Button play = new Button("Play"); | |
play.setOnAction(event -> sequentialTransition.play()); | |
Button pause = new Button("Pause"); | |
pause.setOnAction(event -> sequentialTransition.pause()); | |
HBox hBox = new HBox(10, play, pause); | |
hBox.setAlignment(Pos.CENTER); | |
VBox box = new VBox(20, slide, hBox, status); | |
box.setAlignment(Pos.CENTER); | |
Scene scene = new Scene(box, 300, 250); | |
primaryStage.setScene(scene); | |
primaryStage.show(); | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment