import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; //import javafx.scene.layout.VBox; //import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; //import javafx.scene.text.Font; //import javafx.scene.text.Text; import javafx.scene.control.Button; //import javafx.scene.control.TextField; import javafx.event.EventHandler; import javafx.event.ActionEvent; //import javafx.geometry.Pos; public class MinGUI extends Application { // evt. instansvariabler/konstrukt?r Button knapp = null; @Override public void start(Stage teater) { Pane kulisser = new Pane(); //Button knapp = new Button("Klikk meg!"); knapp = new Button("Klikk meg!"); // legg inn hendelsesh?ndteringen knapp.setOnAction(new KnappBehandler()); kulisser.getChildren().add(knapp); Scene scene = new Scene(kulisser); teater.setScene(scene); teater.show(); } class KnappBehandler implements EventHandler { private int teller = 0; @Override public void handle(ActionEvent e) { teller++; knapp.setText("Klikk nr. " + teller); } } }