-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidateFXML.java
More file actions
41 lines (35 loc) · 1.45 KB
/
ValidateFXML.java
File metadata and controls
41 lines (35 loc) · 1.45 KB
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
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.stage.Stage;
import java.io.File;
import java.net.URL;
public class ValidateFXML extends Application {
@Override
public void start(Stage primaryStage) {
try {
// Try to load the FXML file
File file = new File("src/main/resources/book/javafx/kenyattacatsystem/views/student-dashboard.fxml");
URL url = file.toURI().toURL();
System.out.println("Loading FXML from: " + url);
// This will validate the FXML and check controller compatibility
FXMLLoader loader = new FXMLLoader(url);
Parent root = loader.load();
System.out.println("FXML loaded successfully!");
System.out.println("Controller: " + loader.getController().getClass().getName());
// We don't actually need to show the UI for validation
primaryStage.setTitle("FXML Validator");
primaryStage.setScene(new javafx.scene.Scene(root, 800, 600));
// primaryStage.show();
// Exit after validation
System.exit(0);
} catch (Exception e) {
System.out.println("FXML validation failed: " + e.getMessage());
e.printStackTrace();
System.exit(1);
}
}
public static void main(String[] args) {
launch(args);
}
}