import gioco.progettospacca.classi.Partita;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import java.io.IOException;
public class HomeController {
@FXML
public void giocaPartita(ActionEvent actionEvent) {
}
public void EventoCreaPartita(ActionEvent actionEvent) throws IOException{
Parent root = FXMLLoader.load(getClass().getResource("LoginAdminView.fxml"));
Scene scene=new Scene(root);
Stage stage = (Stage)((Node)actionEvent.getSource()).getScene().getWindow();
stage.setTitle("Login amministratore");
stage.setScene(scene);
stage.show();
}
public void giocaTorneo(ActionEvent actionEvent) {
}
public void creaTorneo(ActionEvent actionEvent) {
}
}```
i get an error saying that
`getClass().getResource("LoginAdminView.fxml") `at line 22 is null
i dont understand why since i have the same setup in the main class and that works. the only difference is that this class is in a subfolder and the main isnt. But i can't figure out what's wrong
#javafx fxml file not found
27 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @vivid pike! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Can I see your project explorer and where you put your LoginAdminView.fxml file?
It should be in the root of your resources folder
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
i dont understand why main.java can find it but controller/homecontroller.java cant
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
.
you named the folder gioco.progettospacc...
it should be a folder named guico with a folder progettospacc... in it
Are you sure? Cause the file is found if i put the getResource in the main
Oh wait they already are 2 folders
intellij just uses a . instad of the /
inside src/main/java, yes
inside src/main/resources, no
at least when I last used IntelliJ
ok
it needs to be in the controller package/directory
ah so resources/gioco/progettospacca/controller?
since you are using getClass().getResource("LoginAdminView.fxml") which requires it to be in the same directory
yes
or you change it to getClass().getClassLoader().getResource("gioco/progettospacca/controller/LoginAdminView.fxml")
yes it works!!
thank you so much
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.