Exception in Application start method
Bonsoir, je suis sur un projet avec JavaFX et j'ai quelques erreurs. J'ai lu les réponses à des questions similaires, mais aucune des solutions ne semble fonctionner. J'espère sincèrement pouvoir trouver de l'aide. Voici le code:
ListController.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| public class ListController implements Initializable {
@FXML
private TableView<Category> categoriesTable;
@FXML
private TableColumn<Category, Integer> idColumn;
@FXML
private TableColumn<Category, String> nameColumn;
@FXML
private TableColumn<Category, String> descriptionColumn;
ObservableList<Category> FXCategories = FXCollections.observableArrayList();
@FXML
private TextField searchField;
/**
* Initializes the controller class.
* @param url
* @param rb
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
initCol();
loadData();
}
private void initCol() {
idColumn.setCellValueFactory(new PropertyValueFactory<>("id"));
nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description"));
}
private void loadData() {
CategoryDAO categoryDAO = new CategoryDAO();
List<dev.stekos.cashregister.entities.Category> categories;
categories = categoryDAO.getAll();
categories.forEach((category) -> {
FXCategories.add(new Category(category.getId(), category.getName(), category.getDescription()));
});
categoriesTable.getItems().setAll(FXCategories);
}
@FXML
private void search(ActionEvent event) {
}
class Category {
private final IntegerProperty id;
private final StringProperty name;
private final StringProperty description;
public Category(int id, String name, String descriptoin) {
this.id = new SimpleIntegerProperty(id);
this.name = new SimpleStringProperty(name);
this.description = new SimpleStringProperty(descriptoin);
}
public int getId() {
return id.get();
}
public String getName() {
return name.get();
}
public String getDescription() {
return description.get();
}
}
} |
ListLoader.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public class ListLoader extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
URL url = ListLoader.class.getResource("list.fxml");
if (url == null) {
System.out.println("Can't load FXML file");
Platform.exit();
}
FXMLLoader loader = new FXMLLoader();
loader.setLocation(url);
loader.setController(new ListController());
BorderPane root;
root = (BorderPane) loader.load();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
} |
Voici la pile d'erreurs que j'ai obtenues lors de l'exécution du code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.8'
warning: The following options were not recognized by any processor: '[eclipselink.canonicalmodel.use_static_factory]'
1 warning
compile-single:
run-single:
Can't load FXML file
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$159(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at dev.stekos.cashregister.views.category.ListLoader.start(ListLoader.java:35)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$166(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$179(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
... 1 more
Exception running application dev.stekos.cashregister.views.category.ListLoader
D:\MyProjects\JAVA\JAVAFX\CashRegister\nbproject\build-impl.xml:1340: The following error occurred while executing this line:
D:\MyProjects\JAVA\JAVAFX\CashRegister\nbproject\build-impl.xml:981: Java returned: 1
BUILD FAILED (total time: 14 seconds) |
Cliquer https://github.com/StephaneKuma/CashRegister pour voir le projet sur github
C'est mon problème, j'espère avoir de l'aide bientôt.