import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.GridPane; import javafx.scene.layout.StackPane; import javafx.scene.text.Text; import javafx.scene.text.Font; import javafx.scene.control.Button; import javafx.scene.shape.Rectangle; import javafx.scene.paint.Color; public class Rutenett extends Application { public void start(Stage stage) { GridPane grid = new GridPane(); int teller = 1; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Text text = new Text(""+teller); text.setFont(new Font(30)); //Button text = new Button(""+teller); StackPane cell = new StackPane(); Rectangle rect = new Rectangle(40, 40); rect.setFill(Color.PALEGREEN); rect.setStroke(Color.BLACK); cell.getChildren().addAll(rect, text); grid.add(cell, j, i); //grid.add(text, j, i); teller++; } } Scene scene = new Scene(grid); stage.setScene(scene); stage.setTitle("Rutenett"); stage.show(); } public static void main(String[] args) { Application.launch(args); } }