0
我在class1中創建了一個場景,然後我在class2中創建了一個scene2。 如何在它們之間切換?在場景之間切換JavaFX
public class class1 extends Application{
Stage window1;
BorderPane layout1;
Scene scene1;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
window1 = primaryStage;
window.setTitle("Stage 1");
// And here is a button which switchs between scenes or stages,
//i dont know what is better.So:
button.setOnAction(e -> ?????????)
scene1 = new Scene(layout1, 800,600);
window1.show();
}
}
這是第二堂課,我有另一個場景。
public class class2 extends Application{
Stage window2;
BorderPane layout2;
Scene scene2;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
window2 = primaryStage;
window2.setTitle("Stage 2");
scene2 = new Scene(layout, 800,600);
window2.show();
}
}
您選擇的方法將不起作用,因爲每個運行時只能有一個'Application'。其餘的請看http://stackoverflow.com/questions/37200845/how-to-switch-scenes-in-javafx – hotzst