GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Source-Code-from-Tutorials/JavaFX/004_switchingScenes/Main.java at master · SF5/Source-Code-from-Tutorials Expand file tree/ Copy pathMain.javaMore file actions 46 lines (35 loc) · 1.2 KB / Copy pathMain.javaFile metadata and controls46 lines (35 loc) · 1.2 KB 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 import javafx.application.*; import javafx.stage.*; import javafx.scene.*; import javafx.scene.layout.*; import javafx.scene.control.*; public class Main extends Application { Stage window; Scene scene1, scene2; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { window = primaryStage; //Button 1 Label label1 = new Label("Welcome to the first scene!"); Button button1 = new Button("Go to scene 2"); button1.setOnAction(e -> window.setScene(scene2)); //Layout 1 - children laid out in vertical column VBox layout1 = new VBox(20); layout1.getChildren().addAll(label1, button1); scene1 = new Scene(layout1, 200, 200); //Button 2 Button button2 = new Button("This sucks, go back to scene 1"); button2.setOnAction(e -> window.setScene(scene1)); //Layout 2 StackPane layout2 = new StackPane(); layout2.getChildren().add(button2); scene2 = new Scene(layout2, 600, 300); //Display scene 1 at first window.setScene(scene1); window.setTitle("Title Here"); window.show(); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |