Есть класс с регистрацией
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
| public class Registration {
@FXML
private Label takeLoginLabel;
@FXML
private TextField nameField;
@FXML
private TextField secondNameField;
@FXML
private TextField schoolNumberField;
@FXML
private TextField gradeField;
@FXML
private TextField gradeLatterField;
public String login;
public void registrate(ActionEvent actionEvent) throws IOException,
IllegalAccessException, ClassNotFoundException, InstantiationException {
LogsWriter lw = new LogsWriter();
String name = nameField.getText();
String LastName = secondNameField.getText();
int grade = Integer.parseInt(gradeField.getText());
String gradeLatter = gradeLatterField.getText();
int schoolNumber = Integer.parseInt(schoolNumberField.getText());
nameField.clear();
secondNameField.clear();
gradeLatterField.clear();
gradeField.clear();
schoolNumberField.clear();
User user = new User();
try {
user.Registration(name, LastName, grade, gradeLatter, schoolNumber);
} catch (SQLException e) {
lw.writeLog("Какая то х**ня с регистрацией");
}
try {
Connection connection = new Connection();
PreparedStatement takeLoginPS = connection.childCon().prepareStatement
("SELECT login FROM childreninfo WHERE secondName = ?");
takeLoginPS.setString(1, LastName);
ResultSet takeLoginRS = takeLoginPS.executeQuery();
while (takeLoginRS.next()) {
login = takeLoginRS.getString("login");
}
} catch (SQLException e) {
lw.writeLog("Ошибка получения логина");
}
Parent take_login = FXMLLoader.load(getClass().getResource("take_login.fxml"));
Scene take_login_scene = new Scene(take_login);
Stage take_login_stage = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow();
take_login_stage.setScene(take_login_scene);
take_login_stage.show();
takeLoginLabel.setText(login); //НЕ ДОБАВЛЯЕТ
}
} |
|
это модальное окно которые при регистрации должно менять сцену и показывать логин который записывается в Label.
этот класс является контроллером 2х fxml файлов
окно регистрации
XML |
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
| <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="349.0" prefWidth="507.0" style="-fx-background-color: #578cb2;" xmlns="http://javafx.com/javafx/8.0.131" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Registration">
<children>
<Label layoutX="234.0" layoutY="38.0" text="Имя">
<font>
<Font name="Calibri Bold Italic" size="16.0" />
</font></Label>
<TextField fx:id="nameField" layoutX="179.0" layoutY="56.0" style="-fx-background-radius: 20;" />
<TextField fx:id="secondNameField" layoutX="179.0" layoutY="109.0" style="-fx-background-radius: 20;" />
<Label layoutX="216.0" layoutY="91.0" text="Фамилия">
<font>
<Font name="Calibri Bold Italic" size="16.0" />
</font></Label>
<Label layoutX="202.0" layoutY="144.0" text="Номер школы">
<font>
<Font name="Calibri Bold Italic" size="16.0" />
</font></Label>
<TextField fx:id="schoolNumberField" layoutX="179.0" layoutY="162.0" style="-fx-background-radius: 20;" />
<Label layoutX="229.0" layoutY="192.0" text="Класс">
<font>
<Font name="Calibri Bold Italic" size="16.0" />
</font></Label>
<TextField fx:id="gradeField" layoutX="179.0" layoutY="210.0" style="-fx-background-radius: 20;" />
<Label layoutX="206.0" layoutY="241.0" text="Буква класса">
<font>
<Font name="Calibri Bold Italic" size="16.0" />
</font></Label>
<TextField fx:id="gradeLatterField" layoutX="179.0" layoutY="259.0" style="-fx-background-radius: 20;" />
<Button layoutX="199.0" layoutY="294.0" mnemonicParsing="false" onAction="#registrate" style="-fx-background-radius: 30; -fx-background-color: #35e529;" text="Регистрация">
<font>
<Font name="Calibri" size="15.0" />
</font></Button>
</children>
</AnchorPane> |
|
и получения логина
XML |
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
| <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="349.0" prefWidth="507.0" style="-fx-background-color: #578cb2;" xmlns="http://javafx.com/javafx/8.0.131" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Registration">
<children>
<Label layoutX="66.0" layoutY="114.0" styleClass="take_login_bg" text="Ваш логин для входа в систему: ">
<font>
<Font name="Calibri Bold" size="16.0" />
</font>
</Label>
<Label fx:id="takeLoginLabel" layoutX="164.0" layoutY="159.0" prefHeight="31.0" prefWidth="180.0" style="-fx-background-color: #d39f37;" text="Label" >
<font>
<Font name="Calibri Bold Italic" size="16.0" />
</font>
</Label>
<Label layoutX="47.0" layoutY="275.0" prefHeight="17.0" prefWidth="434.0" text="Для избежания проблем со входом запишите логин, что бы не забыть его." textFill="RED">
<font>
<Font name="Calibri Bold" size="13.0" />
</font>
</Label>
</children>
</AnchorPane> |
|
при компиляции выдаёт NPE, дебагер говорит что Label = null
ХЕЛП