import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.text.Text; import javafx.scene.control.Button; import javafx.event.EventHandler; import javafx.event.ActionEvent; public class EnkelKnapp extends Application { Button button = null; public void start(Stage stage) { VBox root = new VBox(); button = new Button("Trykk her!"); Knappebehandler k = new Knappebehandler(); button.setOnAction(k); root.getChildren().add(button); Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("Hei!"); stage.show(); } class Knappebehandler implements EventHandler { public void handle(ActionEvent e) { button.setText("Hei verden"); } } public static void main(String[] args) { Application.launch(args); } }