-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdderView.java
39 lines (30 loc) · 1.19 KB
/
AdderView.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
38
39
package it.unimi.di.prog2.esame.view;
import it.unimi.di.prog2.esame.presenter.Presenter;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import org.jetbrains.annotations.NotNull;
public class AdderView extends Region {
private final TextField text = new TextField();
private final TextField num = new TextField();
private final Button addButton = new Button("Add");
public AdderView() {
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))));
num.setPrefColumnCount(2);
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
grid.add(text, 0, 0);
grid.setPadding(new Insets(10, 10, 10, 10));
grid.add(num, 1, 0);
grid.add(addButton, 0, 1);
this.getChildren().add(grid);
}
public void addHandlers(@NotNull Presenter presenter) {
addButton.setOnAction(eh -> presenter.action(Integer.parseInt(num.getText()), text.getText()));
}
}