import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.layout.GridPane; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.scene.paint.Color; import javafx.scene.layout.StackPane; import javafx.scene.shape.Rectangle; public class Oppgave1 extends Application { public void start(Stage teater){ GridPane pane = new GridPane(); int teller = 1; for (int i = 0; i < 3; i++){ for (int j = 0; j < 3; j++){ Text tekst = new Text(Integer.toString(teller)); tekst.setFont(new Font(30)); Rectangle boks = new Rectangle(100, 100, Color.SKYBLUE); boks.setStroke(Color.BLACK); StackPane beholder = new StackPane(); beholder.getChildren().add(boks); beholder.getChildren().add(tekst); pane.add(beholder, j, i); teller++; } } Scene scene = new Scene(pane); teater.setScene(scene); teater.setTitle("Oppgave 1"); teater.show(); } public static void main(String[] args) { launch(args); } }