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; import java.util.Random; public class Hei extends Application{ Button knapp = null; @Override public void start(Stage stage){ knapp = new Button("Si hei!"); Knappebehandler knappebehandler = new Knappebehandler(); knapp.setOnAction(knappebehandler); VBox pane = new VBox(knapp); Scene scene = new Scene(pane); stage.setScene(scene); stage.show(); } class Knappebehandler implements EventHandler{ @Override public void handle(ActionEvent e){ String[] heiListe = {"Hei!", "Hello!", "Salut!", "Guten tag!", "????", "?Hola!", "Ciao!", "Cze??!", "ÄãºÃ"}; Random rand = new Random(); knapp.setText(heiListe[rand.nextInt(heiListe.length-1)]); } } }