Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path Issue? Im not sure what this is but im 100% sure my path seems to be correct #692

Open
abdul2k5 opened this issue Apr 22, 2024 · 0 comments

Comments

@abdul2k5
Copy link

@OverRide
public void start(Stage primaryStage) {
try {
//load the FXML file
FXMLLoader loader = new FXMLLoader(getClass().getResource("/BistroBliss/src/main/java/com/example/bistrobliss/RoleSelection.fxml"));

        Parent root;
        root = loader.<Parent>load();

        //set the scene
        Scene scene = new Scene(root);
        primaryStage.setScene(scene);
        primaryStage.setTitle("BistroBliss - Role Selection");
        primaryStage.show();

        //get the controller and set the image
        RoleSelection controller = loader.getController();
        controller.setImage();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

package com.example.bistrobliss;

import javafx.fxml.FXML;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

import java.util.Objects;

public class RoleSelection {

@FXML
private ImageView imageView;

public void setImage() {
    // Load the image and set it to the ImageView
    Image image = new Image(Objects.requireNonNull(getClass().getResourceAsStream("BistroBliss.jpg")));
    imageView.setImage(image);
}

}

Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at javafx.graphics@22-ea/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics@22-ea/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1147)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics@22-ea/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
at javafx.graphics@22-ea/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
at java.base/java.lang.Thread.run(Thread.java:1570)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml@22-ea/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2561)
at javafx.fxml@22-ea/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2536)
at com.example.bistrobliss/com.example.bistrobliss.BistroBliss.start(BistroBliss.java:82)
at javafx.graphics@22-ea/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
at javafx.graphics@22-ea/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
at javafx.graphics@22-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at javafx.graphics@22-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
at javafx.graphics@22-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at javafx.graphics@22-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics@22-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
... 1 more
Exception running application com.example.bistrobliss.BistroBliss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant