import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.control.Button; import javafx.geometry.Pos; public class HeiPerson extends Application { public void start(Stage stage) { VBox root = new VBox(); root.setAlignment(Pos.CENTER); Label hilsen = new Label("Hei ..."); TextField tekstfelt = new TextField("Skriv ditt navn:"); Button button = new Button("Si hei"); button.setOnAction(e -> { String navn = tekstfelt.getText(); hilsen.setText("Hei " + navn); }); root.getChildren().addAll(hilsen, tekstfelt, button); stage.setScene(new Scene(root)); stage.show(); } }