-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.java
More file actions
83 lines (61 loc) · 2.16 KB
/
Interface.java
File metadata and controls
83 lines (61 loc) · 2.16 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.HPos;
import javafx.geometry.VPos;
import javafx.scene.Scene;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import java.awt.GradientPaint;
import java.util.*;
public class Interface extends Application {
public static final int SIZE = 9;
public static final int ROW = 3;
private Parent createContent() {
VBox root = new VBox(10);
root.setPadding(new Insets(10,10,40,10));
GridPane gridpane = new GridPane();
gridpane.setMinSize(400, 400);
gridpane.setPadding(new Insets(0, 50, 0, 0));
gridpane.setVgap(23);
gridpane.setHgap(23);
// Create the original board
for (int i = 0; i < SIZE; i++) {
List<Tile> tiles = new ArrayList<>();
for (int j = 0; j < SIZE; j++) {
tiles.add(new Tile(String.valueOf(i)));
}
Square square = new Square(tiles);
gridpane.add(square, i % ROW *2, i / ROW *2);
}
gridpane.setAlignment(Pos.CENTER);
// Create input button
HBox buttonHbox = new HBox(10);
Button[] bs = new Button[9];
for (int i = 0; i < 9; i++) {
bs[i] = new Button("" + (i+1));
buttonHbox.getChildren().add(bs[i]);
}
buttonHbox.setAlignment(Pos.CENTER);
// gridpane.add(buttonHbox, 0, 3);
// GridPane.setConstraints(buttonHbox, 0, 3, 2, 3, HPos.CENTER, VPos.CENTER);
root.getChildren().addAll(gridpane, buttonHbox);
return root;
}
public void start(Stage stage) {
stage.setTitle("Sudoku");
stage.setScene(new Scene(createContent()));
stage.show();
}
}