Witam, chciałem napisać implementacje czegoś na styl qmessageboxu z qt, żeby wyświetlić po prostu że user coś źle zrobił. Ale wywala mi błąd przy loaderze, i nie mam pojęcia why... ścieżka jest dobra, plik istnieje i ikona także, niżej kod
package Dialogs;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import java.io.IOException;
public class WarningDialog {
@FXML
Label description;
Stage stage = new Stage();
AnchorPane pane;
public WarningDialog(String header, String note) {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/dialogs/WarningDialog.fxml"));
try {
pane = fxmlLoader.load();
} catch (IOException e) {
e.printStackTrace();
}
Scene scene = new Scene(pane);
stage.setScene(scene);
description.setText(note);
stage.setTitle(header);
stage.setResizable(false);
stage.getIcons().add(new Image("/images/warning.png", 32, 32, true, true));
stage.show();
}
@FXML
private void btnOkClick() {
stage.close();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="250.0" prefWidth="350.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Dialogs.WarningDialog">
<children>
<HBox alignment="BOTTOM_RIGHT" layoutX="87.0" layoutY="136.0" spacing="15.0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<Button maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#btnOkClick" prefHeight="25.0" prefWidth="100.0" text="Ok" />
</children>
<padding>
<Insets bottom="10.0" right="10.0" />
</padding>
</HBox>
<Label fx:id="description" alignment="TOP_LEFT" layoutX="22.0" layoutY="23.0" prefHeight="167.0" prefWidth="295.0" text="Warning..." AnchorPane.leftAnchor="25.0" AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="25.0">
<opaqueInsets>
<Insets />
</opaqueInsets>
</Label>
</children>
</AnchorPane>
i gdy user nie wypełni fieldów w tworzeniu obiektu przez ui
else{
new WarningDialog("Name cannot be empty!", "Please, check your inputs, specially in red fields!");
}