Reputation: 19
I'm working on a project in Eclipse and I want to make use of JavaFX for my GUI. I installed JavaFX and I added it to my project library. When I try to import "import javafx.fxml.FXMLLoader;" there is an error:"The type javafx.fxml.FXMLLoader is not accessible". image: https://ibb.co/QmpFKDF
code:
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Hello extends Application {
public void start(Stage stage) throws Exception {
Parent root = FXMLLOADER.load(getClass().getResource(
"Hello.fxml"));
Scene scene = new Scene(root);
stage.setTitle("Hello");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Thanks.
Upvotes: 0
Views: 5055
Reputation: 4700
First of all Java is case-sensitive as mentioned in the comments. Use FXMLLoader.load()
.
From your screenshot, the IDE recognizes the import line as an error line too. So your JavaFX Library has not been correctly imported.
You have to follow the correct steps to get it to work. Here are some Tutorials that you can follow:
Upvotes: 2