JavaFX Tutorial 4 - Class does not exist! (Remastered)
Автор: Ken
Загружено: 2020-02-21
Просмотров: 1718
1. It means that your JavaFX Main Class (e.g. JavaFXApplication31.java) can’t locate a FXML controller class (e.g. FXMLDocumentController) in a package (e.g. javafaapplication31).
Please refer to your package name, it might be different from mine.
In this tutorial, we made a JavaFXApplication31 project. Under this project, three files are created. All those files should be located in the same package.
Somehow, NetBeans IDE 9.0 does not include a package name for FXML Controller Class when we create a project with a built-in template.
2. In order to fix this issue, you may need to add a correct path to the JavaFX Main Class (e.g. JavaFXApplication31.java). In this example, go to JavaFXApplication31.java then add “/javafxapplication31/” prior to FXMLDocument.fxml.
Before
Parent root = FXMLLoader.load(getClass().getResource(“FXMLDocument.fxml"));
After
Parent root = FXMLLoader.load(getClass().getResource("/javafxapplication31/FXMLDocument.fxml"));
3. You should save it (e.g. JavaFXApplication31.java), then go back to FXMLDocument.fxml to confirm it. The waring of Class does not exist: javafxapplication31.FXMLDocumentController shouldn’t appear.
(Please do not skip this step!)
4. Click on the green Run button to launch the JavaFX application.
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: