Кнопки нажимаются, но ничего не происходит. И так только в этом окне.
package com.example.myapp;
import java.io.IOException;
import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
// Авторизация
public class app6Controller {
@FXML
private ResourceBundle resources;
@FXML
private URL location;
@FXML
private Button exitButton;
@FXML
private TextField loginField;
@FXML
private PasswordField passwordField;
@FXML
private Button regButton;
@FXML
private Button signButton;
@FXML
void initialize() {
signButton.setOnAction(event -> {
String login = loginField.getText().trim();
String password = passwordField.getText().trim();
if(!login.equals("") && !password.equals("")){
loginUser(login, password);
} else {
System.out.println("Error");
}
});
exitButton.setOnAction(event -> {
System.out.println("Всё работает");
});
regButton.setOnAction(event -> {
regButton.getScene().getWindow().hide();
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("hello-view2.fxml"));
try {
loader.load();
} catch (IOException e) {
e.printStackTrace();
}
Parent root = loader.getRoot();
Stage stage = new Stage();
stage.setScene(new Scene(root, 699, 500));
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
});
}
private void loginUser(String login, String password) {
DataBaseHandler dataBaseHandler = new DataBaseHandler();
User user = new User();
user.setLogin(login);
user.setPassword(password);
ResultSet resultSet = dataBaseHandler.getUser(user);
int count = 0;
while (true){
try {
if (!resultSet.next()) break;
} catch (SQLException e) {
e.printStackTrace();
}
count++;
}
if(count >= 1){
System.out.println("Success");
}
}
}
И его fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="497.0" prefWidth="699.0" style="-fx-background-color: #2E3349;" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane layoutX="-9.0" layoutY="81.0" prefHeight="419.0" prefWidth="708.0" style="-fx-background-color: #fafafa; -fx-border-radius: 5;">
<children>
<Label layoutX="14.0" layoutY="363.0" prefHeight="45.0" prefWidth="317.0" text="Авторизация">
<font>
<Font name="ft40 Roman" size="44.0" />
</font>
</Label>
<Label layoutX="23.0" layoutY="349.0" opacity="0.13" prefHeight="45.0" prefWidth="317.0" text="Авторизация">
<font>
<Font name="ft40 Roman" size="44.0" />
</font>
</Label>
<Label layoutX="187.0" layoutY="55.0" text="Введите ваш ник:">
<font>
<Font name="ft40 Roman" size="36.0" />
</font>
</Label>
<Label layoutX="154.0" layoutY="171.0" text="Введите ваш пароль:">
<font>
<Font name="ft40 Roman" size="36.0" />
</font>
</Label>
<TextField fx:id="loginField" layoutX="229.0" layoutY="106.0" prefHeight="39.0" prefWidth="251.0" promptText="Fareny">
<font>
<Font name="ft40 Roman" size="22.0" />
</font>
</TextField>
<PasswordField fx:id="passwordField" layoutX="229.0" layoutY="220.0" prefHeight="39.0" prefWidth="251.0" promptText="123456789">
<font>
<Font name="ft40 Roman" size="20.0" />
</font>
</PasswordField>
<Button fx:id="signButton" layoutX="591.0" layoutY="366.0" mnemonicParsing="false" prefHeight="39.0" prefWidth="103.0" style="-fx-background-color: #2E3349;" text="Войти" textFill="WHITE">
<font>
<Font name="ft40 Roman" size="18.0" />
</font>
</Button>
<Button fx:id="regButton" layoutX="427.0" layoutY="366.0" mnemonicParsing="false" prefHeight="39.0" prefWidth="155.0" style="-fx-background-color: #ffcc66;" text="Регистрация">
<font>
<Font name="ft40 Roman" size="18.0" />
</font>
</Button>
</children>
</AnchorPane>
<Label layoutX="262.0" layoutY="14.0" prefHeight="45.0" prefWidth="176.0" text="MineHelper" textFill="WHITE">
<font>
<Font name="ft40 Roman" size="30.0" />
</font>
</Label>
<Button fx:id="exitButton" layoutX="557.0" layoutY="18.0" mnemonicParsing="false" prefHeight="37.0" prefWidth="128.0" style="-fx-background-color: #ffcc66;" text="Exit">
<font>
<Font name="ft40 Roman" size="18.0" />
</font>
</Button>
</children>
</AnchorPane>