-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
75 lines (64 loc) · 2.37 KB
/
Main.java
File metadata and controls
75 lines (64 loc) · 2.37 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
package Snowman;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
void draw(Pane root2, int min, int max, int count){
Snowman snowman = new Snowman();
Circle head = null;
for (int i = 0; i < count; i++) {
if (i == 0) {
head = snowman.createFirstCircle(root2, min, max);
} else head = snowman.createCircle(head, root2, min, max);
}
}
void initWindow(Pane root, Pane root2) {
TextField countOfCircles = new TextField();
countOfCircles.setTranslateX(10);
countOfCircles.setTranslateY(10);
countOfCircles.setPromptText("Кол-во кругов");
TextField minRadius = new TextField();
minRadius.setTranslateX(10);
minRadius.setTranslateY(40);
minRadius.setPromptText("Минимальный радиус");
TextField maxRadius = new TextField();
maxRadius.setTranslateX(10);
maxRadius.setTranslateY(70);
maxRadius.setPromptText("Максимальный радиус");
Button draw = new Button("Draw");
draw.setTranslateX(10);
draw.setTranslateY(100);
draw.setOnAction(event -> {
root2.getChildren().clear();
int min = 0;
int max = 0;
int count = 0;
try {
min = Integer.parseInt(minRadius.getText());
max = Integer.parseInt(maxRadius.getText());
count = Integer.parseInt(countOfCircles.getText());
} catch (NumberFormatException nbe) {
System.out.println("Неверный формат");
return;
}
draw(root2, min, max, count);
});
root.getChildren().addAll(countOfCircles, minRadius, maxRadius, draw);
}
@Override
public void start(Stage primaryStage) throws Exception {
Pane root = new Pane();
Pane root2 = new Pane();
root.getChildren().add(root2);
initWindow(root, root2);
primaryStage.setScene(new Scene(root, 600, 600));
primaryStage.show();
}
}