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 Hello extends Application { Button knapp = null; @Override public void start (Stage teater) { knapp = new Button("Si hei!"); Knappebehandler behandler = new Knappebehandler(); knapp.setOnAction(behandler); VBox pane = new VBox(knapp); teater.setTitle("Velkommen til Java FX"); teater.setScene(new Scene(pane)); teater.show(); } public static void main(String[] args) { launch(args); } class Knappebehandler implements EventHandler { @Override public void handle(ActionEvent e) { knapp.setText(String.format("Hei verden!")); } } }