JavaFX Working Except for FXMLLoader Import

30 views Asked by At

When I was searching for a solution I noticed most people's issues was an incorrect installation. I believe my installation is correct as a normal JavaFX project works fine. However, I am not able to import the FXMLLoader or use it in my Java project. All jars have been added to my JavaFX19 user library.

I am using Eclipse 09-2022, Java 19, JavaFX19.

Error Message on Import: The type javafx.fxml.FXMLLoader is not accessible


package application;
    
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;


public class Main extends Application {
    
    public static void main(String[] args) {
        // Launches stage and goes to start.
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        
        Parent root = FXMLLoader.load(getClass().getResource("FXMLHomeScreen.fxml"));
        Scene homeScreen = new Scene(root, 1000, 700, Color.BLACK);
        stage.setScene(homeScreen);
        stage.show();
    }
}

EDIT: Adding module-info.java as requested.

module ResellingManager {
    requires javafx.controls;
    requires javafx.graphics;
    
    opens application to javafx.graphics, javafx.fxml;
}
0

There are 0 answers