This is the main code, I'm having problems with FXMLLoader, since I tried several ways and the path is never found.
package com.quixada.ufc.fbd.main;
import java.util.ArrayList;
import com.quixada.ufc.fbd.viewFXController.OnChangeScreen;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.fxml.FXMLLoader;
public class MainJavaFX extends Application {
private static Stage stage;
private static Scene mainScene;
private static Scene detailsScene;
private static ArrayList<OnChangeScreen> listeners = new ArrayList<>();
@Override
public void start(Stage primaryStage) {
try {
stage = primaryStage;
primaryStage.setTitle("Exemplo");
AnchorPane fxmlMain = (AnchorPane)FXMLLoader.load(getClass().getResource("../com/quixada/ufc/fbd/view/ViewLogin.fxml"));
mainScene = new Scene(fxmlMain,400,400);
AnchorPane fxmlDetails = (AnchorPane)FXMLLoader.load(getClass().getResource("/src/com.quixada.ufc.fbd.view/ViewCadastro.fxml"));
detailsScene = new Scene(fxmlDetails,400,400);
primaryStage.setScene(mainScene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void changeScreen(String scr, Object userData) {
switch (scr) {
case "main":
stage.setScene(mainScene);
notifyAllListeners("main", userData);
break;
case "details":
stage.setScene(detailsScene);
notifyAllListeners("details", userData);
}
}
public static void changeScreen(String scr) {
changeScreen(scr, null);
}
public static void main(String[] args) {
launch(args);
}
public static void addOnChangeScreenListener(OnChangeScreen newListener) {
listeners.add(newListener);
}
private static void notifyAllListeners(String newScreen, Object userData) {
for (OnChangeScreen l : listeners)
l.onScreenChanged(newScreen, userData);
}
I am organizing my packages as follows:
Could someone give me some help?