transition java fx

Solutions on MaxInterview for transition java fx by the best coders in the world

showing results for - "transition java fx"
Giovanni
26 Aug 2018
1import javafx.animation.TranslateTransition;
2import javafx.application.Application;
3import javafx.scene.Scene;
4import javafx.scene.layout.VBox;
5import javafx.scene.text.Font;
6import javafx.scene.text.Text;
7import javafx.stage.Stage;
8import javafx.util.Duration;
9 
10public class FxTransitionExample3 extends Application
11{
12    public static void main(String[] args) 
13    {
14        Application.launch(args);
15    }
16     
17    @Override
18    public void start(Stage stage) 
19    {
20        // Create the Text
21        Text text = new Text("A Translate Transition Example");
22        text.setFont(Font.font(36));
23 
24        // Create the VBox
25        VBox root = new VBox(text);
26        // Set the Size of the VBox
27        root.setPrefSize(500, 100);
28        // Set the Style-properties of the VBox
29        root.setStyle("-fx-padding: 10;" +
30                "-fx-border-style: solid inside;" +
31                "-fx-border-width: 2;" +
32                "-fx-border-insets: 5;" +
33                "-fx-border-radius: 5;" +
34                "-fx-border-color: blue;");
35         
36        // Create the Scene
37        Scene scene = new Scene(root);
38        // Add the Scene to the Stage
39        stage.setScene(scene);
40        // Set the Title
41        stage.setTitle("Scrolling Text using a Translate Transition");
42        // Display the Stage
43        stage.show();
44 
45        // Set up a Translate Transition for the Text object
46        TranslateTransition trans = new TranslateTransition(Duration.seconds(2), text);
47        trans.setFromX(scene.getWidth());
48        trans.setToX(-1.0 * text.getLayoutBounds().getWidth());
49        // Let the animation run forever
50        trans.setCycleCount(TranslateTransition.INDEFINITE);
51        // Reverse direction on alternating cycles
52        trans.setAutoReverse(true);
53        // Play the Animation
54        trans.play();       
55    }
56}
57
Alyson
11 Jan 2018
1import javafx.animation.FadeTransition;
2import javafx.application.Application;
3import javafx.scene.Scene;
4import javafx.scene.layout.HBox;
5import javafx.scene.paint.Color;
6import javafx.scene.shape.Rectangle;
7import javafx.stage.Stage;
8import javafx.util.Duration;
9 
10public class FxTransitionExample1 extends Application
11{
12    public static void main(String[] args) 
13    {
14        Application.launch(args);
15    }
16     
17    @Override
18    public void start(Stage stage) 
19    {
20        // Create a green Rectangle
21        Rectangle rect = new Rectangle(400, 200, Color.GREEN);
22        // Create the HBox
23        HBox root = new HBox(rect);
24        // Set the Style-properties of the HBox
25        root.setStyle("-fx-padding: 10;" +
26                "-fx-border-style: solid inside;" +
27                "-fx-border-width: 2;" +
28                "-fx-border-insets: 5;" +
29                "-fx-border-radius: 5;" +
30                "-fx-border-color: blue;");
31 
32        // Create the Scene
33        Scene scene = new Scene(root);
34        // Add the Scene to the Stage
35        stage.setScene(scene);
36        // Set the Title of the Stage
37        stage.setTitle("A Fade-in and Fade-out Transition Example");
38        // Display the Stage
39        stage.show();
40         
41        // Set up a fade-in and fade-out animation for the rectangle
42        FadeTransition trans = new FadeTransition(Duration.seconds(2), rect);
43        trans.setFromValue(1.0);
44        trans.setToValue(.20);
45        // Let the animation run forever
46        trans.setCycleCount(FadeTransition.INDEFINITE);
47        // Reverse direction on alternating cycles
48        trans.setAutoReverse(true);
49        // Play the Animation
50        trans.play();
51    }
52}
53