-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
194 lines (167 loc) · 7.36 KB
/
Main.java
File metadata and controls
194 lines (167 loc) · 7.36 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.*;
import static java.lang.Thread.sleep;
class main1 {
public static void main(String[] args) throws IOException {
JFrame window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
window.setSize(200,200);
JButton button = new JButton();
button.setText("Высчитать");
button.setSize(100, 100);
JTextField firstSample = new JTextField(10);
JTextField secondSample = new JTextField(10);
JTextField averageFirstSample = new JTextField(10);
JTextField averageSecondSample = new JTextField(10);
JTextField dispersionFirstSample = new JTextField(10);
JTextField dispersionSecondSample = new JTextField(10);
JTextField standartDeviationFirstSample = new JTextField(10);
JTextField standartDeviationSecondSample = new JTextField(10);
JTextField standartErrorFirstSample = new JTextField(10);
JTextField standartErrorSecondSample = new JTextField(10);
JTextField testT = new JTextField(10);
JTextField correlation = new JTextField(10);
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
panel.setSize(100, 300);
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
gbc.gridy = 0;
gbc.gridx = 0;
panel.add(new JLabel("Первая выборка :"), gbc);
gbc.gridy = 0;
gbc.gridx = 1;
panel.add(firstSample, gbc);
gbc.gridy = 1;
gbc.gridx = 0;
panel.add(new JLabel("Вторая выборка :"), gbc);
gbc.gridy = 1;
gbc.gridx = 1;
panel.add(secondSample, gbc);
gbc.gridy = 2;
gbc.gridx = 1;
panel.add(button, gbc);
gbc.gridy = 3;
gbc.gridx = 0;
panel.add(new JLabel("Среднее первой выборки :"), gbc);
gbc.gridy = 3;
gbc.gridx = 1;
panel.add(averageFirstSample, gbc);
gbc.gridy = 4;
gbc.gridx = 0;
panel.add(new JLabel("Среднее второй выборки :"), gbc);
gbc.gridy = 4;
gbc.gridx = 1;
panel.add(averageSecondSample, gbc);
gbc.gridy = 5;
gbc.gridx = 0;
panel.add(new JLabel("Стандартное отклонение первой выборки :"), gbc);
gbc.gridy = 5;
gbc.gridx = 1;
panel.add(standartDeviationFirstSample, gbc);
gbc.gridy = 6;
gbc.gridx = 0;
panel.add(new JLabel("Стандартное отклонение второй выборки :"), gbc);
gbc.gridy = 6;
gbc.gridx = 1;
panel.add(standartDeviationSecondSample, gbc);
gbc.gridy = 7;
gbc.gridx = 0;
panel.add(new JLabel("Стандартная ошибка первой выборки :"), gbc);
gbc.gridy = 7;
gbc.gridx = 1;
panel.add(standartErrorFirstSample, gbc);
gbc.gridy = 8;
gbc.gridx = 0;
panel.add(new JLabel("Стандартная ошибка второй выборки :"), gbc);
gbc.gridy = 8;
gbc.gridx = 1;
panel.add(standartErrorSecondSample, gbc);
gbc.gridy = 9;
gbc.gridx = 0;
panel.add(new JLabel("Дисперсия первой выборки :"), gbc);
gbc.gridy = 9;
gbc.gridx = 1;
panel.add(dispersionFirstSample, gbc);
gbc.gridy = 10;
gbc.gridx = 0;
panel.add(new JLabel("Дисперсия второй выборки :"), gbc);
gbc.gridy = 10;
gbc.gridx = 1;
panel.add(dispersionSecondSample, gbc);
gbc.gridy = 11;
gbc.gridx = 0;
panel.add(new JLabel("Критерий Стьюдента :"), gbc);
gbc.gridy = 11;
gbc.gridx = 1;
panel.add(testT, gbc);
gbc.gridy = 12;
gbc.gridx = 0;
panel.add(new JLabel("Корреляция выборок :"), gbc);
gbc.gridy = 12;
gbc.gridx = 1;
panel.add(correlation, gbc);
window.add(panel);
ActionListener AListener1 = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Hello, world!");
try {
String fileName = "C://interface//interface.txt";
try {
PrintWriter pw = new PrintWriter(fileName);
pw.close();
} catch (IOException er) {
er.printStackTrace();
}
File file1 = new File("C://interface", "interface.txt");
FileWriter writer = new FileWriter(file1, false);
writer.write(firstSample.getText());
writer.write("\n");
writer.write(secondSample.getText());
writer.flush();
writer.close();
Runtime.getRuntime().exec("cmd.exe /c start C:\\Users\\Omar\\Desktop\\SelfStudy\\Cpp\\withVector.exe");
sleep(100);
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
averageFirstSample.setText("23");
System.out.println("!!!\n");
try {
File file = new File("C://interface//feedback.txt");
FileReader fr = new FileReader(file);
BufferedReader reader = new BufferedReader(fr);
String line = reader.readLine();
String[] num = new String(line).replaceAll(",", ".").split(" ");
averageFirstSample.setText(String.valueOf(Double.parseDouble(num[0])));
averageSecondSample.setText(String.valueOf(Double.parseDouble(num[1])));
dispersionFirstSample.setText(String.valueOf(Double.parseDouble(num[2])));
dispersionSecondSample.setText(String.valueOf(Double.parseDouble(num[3])));
standartDeviationFirstSample.setText(String.valueOf(Double.parseDouble(num[4])));
standartDeviationSecondSample.setText(String.valueOf(Double.parseDouble(num[5])));
standartErrorFirstSample.setText(String.valueOf(Double.parseDouble(num[6])));
standartErrorSecondSample.setText(String.valueOf(Double.parseDouble(num[7])));
testT.setText(String.valueOf(Double.parseDouble(num[8])));
correlation.setText(String.valueOf(Double.parseDouble(num[9])));
} catch (FileNotFoundException err) {
err.printStackTrace();
} catch (IOException err) {
err.printStackTrace();
}
}
};
button.addActionListener(AListener1);
}
}