import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.event.EventHandler; import javafx.event.ActionEvent; public class HeiVerden extends Application{ Button knapp = null; public TextField tekstfelt = null; @Override public void start(Stage stage){ knapp = new Button("Si hei"); KnappeBehandler behandler = new KnappeBehandler(); knapp.setOnAction(behandler); tekstfelt = new TextField("Hilsen"); VBox pane = new VBox(knapp); pane.getChildren().add(tekstfelt); stage.setScene(new Scene(pane)); stage.show(); } class KnappeBehandler implements EventHandler{ @Override public void handle(ActionEvent e){ String hilsen = tekstfelt.getText(); knapp.setText(hilsen); } } }