Bonjour,
Je veut realiser une application graphique en javafx , et j'ai commencer comme sa
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
package pfe2;
 
/**
 * Copyright (c) 2008, 2012 Oracle and/or its affiliates.
 * All rights reserved. Use is subject to license terms.
 */
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.animation.*;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
 
/**
 * A sample in which various transitions are executed sequentially.
 *
 * @related animation/transitions/FadeTransition
 * @related animation/transitions/FillTransition
 * @related animation/transitions/ParallelTransition
 * @related animation/transitions/PathTransition
 * @related animation/transitions/PauseTransition
 * @related animation/transitions/RotateTransition
 * @related animation/transitions/ScaleTransition
 * @related animation/transitions/StrokeTransition
 * @related animation/transitions/TranslateTransition
 * @see javafx.animation.SequentialTransition
 * @see javafx.animation.Transition
 */
public class SequentialTransitionSample extends Application {
 
    private SequentialTransition sequentialTransition,s2,s3,s4,s5;
 
    private void init(Stage primaryStage) {
        Group root = new Group();
        primaryStage.setResizable(false);        
        primaryStage.setScene(new Scene(root, 705,629));
        final Button btn1 = new Button();
        final Button btn2 = new Button();
        final Button btn3 = new Button();
        final Button btn4 = new Button();
        final Button btn5 = new Button();
 
        btn1.setText("→");
        btn2.setText("↓");
        btn3.setText("←");
        btn4.setText("↑");
        btn5.setText("tourner");
 
        btn1.setPrefSize(50, 30);btn1.setLayoutX(600);btn1.setLayoutY(50);
        root.getChildren().add(btn1);
 
 
 
        btn2.setPrefSize(50, 30);btn2.setLayoutX(600);btn2.setLayoutY(100);
        root.getChildren().add(btn2);
 
        btn3.setPrefSize(50, 30);btn3.setLayoutX(600);btn3.setLayoutY(150);
        root.getChildren().add(btn3);
 
        btn4.setPrefSize(50, 30);btn4.setLayoutX(600);btn4.setLayoutY(200);
        root.getChildren().add(btn4);
 
         btn5.setPrefSize(100, 30);btn5.setLayoutX(600);btn5.setLayoutY(250);
        root.getChildren().add(btn5);
 
// create rectangle
        Rectangle rect = new Rectangle(-25,-25,50, 50);
        rect.setArcHeight(15);
        rect.setArcWidth(15);
        rect.setFill(Color.CRIMSON);
        rect.setTranslateX(50);
        rect.setTranslateY(50);
        root.getChildren().add(rect);
//dessin de la grille
        for (int i=15;i<609;i+=70)
   for(int j=25;j<629;j+=50)
           {Line line = new Line(i, j, i, j);
           line.setStrokeWidth(10);//largeur ligne
root.getChildren().add(line);}
        // create 4 transitions
 
        TranslateTransition translateTransition =
                TranslateTransitionBuilder.create()
                .duration(Duration.seconds(10))
                .fromX(50)
                .toX(540)
                .cycleCount(1)
               // .autoReverse(true)
                .build();       
        TranslateTransition translateTransition1 = 
                TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromY(50)
                .toY(600)
                .cycleCount(1)
                .autoReverse(false)
                .build();
 
        TranslateTransition translateTransition2 = 
                TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromX(540)
                .toX(50)
                .cycleCount(1)
                .autoReverse(false)
                .build();
 
         TranslateTransition translateTransition3 = 
                TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromY(550)
                .toY(50)
                .cycleCount(1)
                .autoReverse(false)
                .build();
 
         RotateTransition rotateTransition = 
                RotateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .byAngle(90)
                .cycleCount(1)
                .autoReverse(false)
                .build();
         RotateTransition rotateTransition1 = 
                RotateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .byAngle(90)
                .cycleCount(1)
                .autoReverse(false)
                .build();
         RotateTransition rotateTransition2 = 
                RotateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .byAngle(90)
                .cycleCount(1)
                .autoReverse(false)
                .build();
 
         btn1.setOnAction(new EventHandler<ActionEvent>() {
    @Override public void handle(ActionEvent e) {
      sequentialTransition.play();
    }    
});
         btn2.setOnAction(new EventHandler<ActionEvent>() {
    @Override public void handle(ActionEvent e) {
      s2.play();
    }    
});
         btn3.setOnAction(new EventHandler<ActionEvent>() {
    @Override public void handle(ActionEvent e) {
      s3.play();
    }    
});
         btn4.setOnAction(new EventHandler<ActionEvent>() {
    @Override public void handle(ActionEvent e) {
      s4.play();
    }    
});
 
          btn5.setOnAction(new EventHandler<ActionEvent>() {
    @Override public void handle(ActionEvent e) {
      s5.play();
    }    
});
        // s2,s3,s4,s5 sont les 4 mouvement a realsier (avancer )    
         s2 = SequentialTransitionBuilder.create()
                .node(rect)
                .children( 
                           translateTransition1)
                .cycleCount(1)
                .autoReverse(false)
                .build();
        s3 = SequentialTransitionBuilder.create()
                .node(rect)
                .children( 
                           translateTransition2)
                .cycleCount(1)
                .autoReverse(false)
                .build(); 
        s4 = SequentialTransitionBuilder.create()
                .node(rect)
                .children( 
                           translateTransition3)
                .cycleCount(1)
                .autoReverse(false)
                .build();
        s5 = SequentialTransitionBuilder.create()
                .node(rect)
                .children( 
                           rotateTransition)
                .cycleCount(1)
                .autoReverse(false)
                .build();
 
         sequentialTransition = SequentialTransitionBuilder.create()
                .node(rect)
                .children( translateTransition/*,rotateTransition ,
                           translateTransition1,rotateTransition1,
                           translateTransition2,rotateTransition2,
                           translateTransition3/**/)
                .cycleCount(1)
                .autoReverse(false)
                .build();
    }
 
 
    public void play() {
 
      //sequentialTransition.play();
    }
 
    @Override public void stop() {
        sequentialTransition.stop();
    }
 
    public double getSampleWidth() { return 400; }
 
    public double getSampleHeight() { return 100; }
 
    @Override public void start(Stage primaryStage) throws Exception {
        init(primaryStage);
        primaryStage.show();
        play();
 
    }
    public static void main(String[] args) { launch(args); }
}
mais le problème est que tous dans une seule classe , et moi je veut le rendre a la fin mais dispatché dans plusieurs classes par exemple :
une classe qui affiche la fenêtre dont je crée des objets des autre classe qui sont :
une classe qui dessine le carré
une classe qui crée les boutons a coté du carré

en gros je veut savoir comment appeler launch depuis une autre classe
Merci d'avance.

c'est