-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeamsAdminController.java
More file actions
88 lines (75 loc) · 2.14 KB
/
Copy pathTeamsAdminController.java
File metadata and controls
88 lines (75 loc) · 2.14 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
80
81
82
83
84
85
86
87
88
import javafx.fxml.FXML;
import javafx.scene.layout.VBox;
import javafx.scene.control.TextField;
import javafx.scene.control.Button;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import java.io.FileWriter;
import java.io.IOException;
import javafx.stage.Stage;
public class TeamsAdminController {
@FXML
private VBox PointsButtons;
@FXML
private VBox PointsFields;
@FXML
private VBox TeamsButtons;
@FXML
private VBox TeamsTextFields;
//varr
private TextField[] Teams;
private TextField[] Points;
private Button UpdatePoints;
private Button UpdateTeams;
private String data;
public void initialize()
{
data = "";
Teams = new TextField[10];
Points = new TextField[10];
UpdateTeams = new Button();
UpdatePoints = new Button();
UpdatePoints.setText("Update");
UpdateTeams = new Button();
UpdateTeams.setText("Update");
UpdateTeams.setOnAction(event);
UpdatePoints.setOnAction(event);
for(int i = 0; i < 10; i++)
{
Teams[i] = new TextField();
Points[i] = new TextField();
TeamsTextFields.getChildren().add(Teams[i]);
PointsFields.getChildren().add(Points[i]);
}
PointsButtons.getChildren().add(UpdatePoints);
TeamsButtons.getChildren().add(UpdateTeams);
}
EventHandler<ActionEvent> event = new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
data = "";
for(int i = 0; i < 10; i++)
{
if(!Teams[i].getText().equals(""))
{
data+=Teams[i].getText() + ",";
if(Points[i].getText() != null)
data+=Points[i].getText();
if(Points[i].getText().equals(""))
data += "0";
data+="\n";
}
}
System.out.println(data);
try {
FileWriter fw = new FileWriter("teams.csv");
fw.write(data);
System.out.println("Successfully written");
fw.close();
}
catch (Exception exc) {
exc.getStackTrace();
}
}
};
}