import javafx.application.Application; import javafx.scene.layout.*; import javafx.scene.*; import javafx.scene.control.*; import javafx.stage.Stage; import javafx.scene.text.*; import javafx.scene.shape.Rectangle; import javafx.scene.paint.*; import javafx.event.*; public class HeiVerden extends Application { Button knapp = null; @Override public void start(Stage stage) { VBox root = new VBox(); knapp = new Button("Si hei"); knapp.setOnAction(new Knappebehandler()); root.getChildren().add(knapp); stage.setScene(new Scene(root, 200, 200)); stage.show(); } class Knappebehandler implements EventHandler { @Override public void handle(ActionEvent e) { knapp.setText("Hei!"); knapp.setOnAction(new Knappebehandler2()); } } class Knappebehandler2 implements EventHandler { @Override public void handle(ActionEvent e) { knapp.setText("Surprise!"); knapp.setOnAction(new Knappebehandler()); } } }