import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.control.Button; import javafx.event.EventHandler; import javafx.event.ActionEvent; public class HeiVerden extends Application { Button knapp = null; @Override public void start(Stage stage) { knapp = new Button("Si hei!"); knapp.setPrefSize(100, 100); Knappebehandler behandler = new Knappebehandler(); knapp.setOnAction(behandler); VBox box = new VBox(knapp); stage.setScene(new Scene(box)); stage.show(); } private class Knappebehandler implements EventHandler { @Override public void handle(ActionEvent e) { knapp.setText("Hei verden!"); } } }