import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.shape.Rectangle; public class Scener extends Application{ public void start(Stage stage){ // Scene 1 Button knapp1 = new Button("Trykk her"); Pane root1 = new Pane(knapp1); Scene scene1 = new Scene(root1); // Scene 2 Button knapp2 = new Button("Ikke trykk her!"); TextField tekstfelt = new TextField(); Rectangle firkant = new Rectangle(50, 50); VBox root2 = new VBox(knapp2, tekstfelt, firkant); Scene scene2 = new Scene(root2); firkant.setOnMouseClicked(e -> { knapp2.setText(tekstfelt.getText()); }); knapp1.setOnAction(e -> { stage.setScene(scene2); }); stage.setScene(scene1); stage.setTitle("Sceneprogram"); stage.show(); } }