-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGridRectangleDisplay.java
More file actions
34 lines (28 loc) · 952 Bytes
/
GridRectangleDisplay.java
File metadata and controls
34 lines (28 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class GridRectangleDisplay extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
GridPane grid = new GridPane();
int rectSize = 50;
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
Rectangle rect = new Rectangle(rectSize, rectSize);
rect.setStroke(Color.BLACK);
rect.setFill(Color.LIGHTGRAY);
grid.add(rect, col, row);
}
}
Scene scene = new Scene(grid);
primaryStage.setTitle("3x3 Grid of Rectangles");
primaryStage.setScene(scene);
primaryStage.show();
}
}