-
Notifications
You must be signed in to change notification settings - Fork 0
/
DisplayView.java
37 lines (32 loc) · 1.16 KB
/
DisplayView.java
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
35
36
37
package it.unimi.di.prog2.esame.view;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import org.jetbrains.annotations.NotNull;
public class DisplayView extends Region {
private final Label[] rows;
public DisplayView(int rows, String title) {
this.rows = new Label[rows];
setBackground(new Background(
new BackgroundFill(Color.LIGHTBLUE, new CornerRadii(5.0), Insets.EMPTY)));
setBorder(new Border(
new BorderStroke(null, BorderStrokeStyle.SOLID, new CornerRadii(5.0), new BorderWidths(2))));
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
Label title1 = new Label(title);
title1.setFont(Font.font("sans", 20));
grid.add(title1, 0,0);
for (int i = 0; i < rows; i++) {
this.rows[i] = new Label("Row #" + i);
this.rows[i].setPadding(new Insets(10, 10, 10, 10));
this.rows[i].setFont(Font.font("monospace", 14));
grid.add(this.rows[i], 0, i+1);
}
this.getChildren().add(grid);
}
public void set(int i, @NotNull String s) {
rows[i].setText(s);
}
}