file-type

JavaFX-Tabs教程:掌握FXML标签集成与控制器注入

ZIP文件

下载需积分: 50 | 8KB | 更新于2025-02-12 | 83 浏览量 | 0 下载量 举报 收藏
download 立即下载
在本段落中,我们需要详细解释JavaFX中如何使用带有fxml标签的选项卡功能,以及它们如何与子控制器交互。教程的目标用户可能已经熟悉JavaFX的基础知识,但对于选项卡组件的高级功能,以及如何实现标签计数器与子控制器之间通信的具体方法可能还不太熟悉。 ### JavaFX中的Tabs组件 **JavaFX** 是一个用于构建桌面应用程序的Java库,它提供了一套丰富的UI组件。**Tabs(选项卡)**是其中一种用于组织信息的UI控件,它们允许用户在多个标签页之间切换,每个标签页可以展示不同的内容区域。 #### 使用FXML管理视图 **FXML(JavaFX Markup Language)** 是一种用于描述用户界面的XML语言。它允许开发者以声明方式定义界面,从而与Java代码分离。在FXML中定义的每个标签页都可以包含自己的FXML文件,这样做的好处是能够使得界面结构更清晰,且易于维护。 每个FXML文件都可以有它自己的**fx:id**,这相当于给这个FXML文件定义了一个"标签名"。在主FXML文件中,可以通过这个fx:id引用对应的子FXML,并获取其控制器的实例。 #### 子控制器和主控制器的交互 在JavaFX中,每个FXML文件都可能拥有一个控制器(Controller),这个控制器是一个普通的Java类,用于处理该视图组件的逻辑。在本教程中,主控制器(MainController)需要能够访问和操作所有子控制器。这通常是通过在主FXML文件中引用子FXML的fx:id来完成的。通过这种方式,主控制器可以直接调用子控制器的方法或访问其属性。 #### 启动子控制器的方法 教程中还提到了如何从主控制器中启动子控制器的方法。在**Main.java**中,需要创建一个公共静态的**FXMLLoader**,这个加载器负责加载主FXML文件。一旦加载了主FXML,你就可以通过主控制器访问其他子控制器了。 #### 实现标签计数器 本教程还涉及到了创建一个标签计数器,并与子控制器进行交互。标签计数器是一个用于跟踪当前选中标签页数量的组件。由于子控制器之间的逻辑可能会相互影响,因此需要合理的通信机制,这通常通过主控制器来实现。 ### 示例代码分析 由于没有给出具体的代码示例,我们仅能根据描述猜测实现的细节。以下是一些可能用到的关键代码段落: ```java // Main.java public class Main { public static void main(String[] args) { launch(args); } public static FXMLLoader loader; // 用于加载FXML文件的公共静态FXMLLoader @Override public void start(Stage primaryStage) { // 初始化FXMLLoader loader = new FXMLLoader(getClass().getResource("Main.fxml")); Parent root = loader.load(); // 获取主控制器 MainController mainController = loader.getController(); // 使用主控制器访问子控制器 // 示例:mainController.getChildController().doSomething(); // 显示舞台 primaryStage.setScene(new Scene(root)); primaryStage.show(); } } // MainController.java public class MainController { // 子控制器的引用 private ChildController childController; public void setChildController(ChildController controller) { this.childController = controller; } public void doAction() { // 主控制器执行的动作,可能涉及到子控制器 if (childController != null) { childController.doSomething(); } } } // ChildController.java public class ChildController { // 子控制器的逻辑 public void doSomething() { // 实现某些功能... } } ``` 通过上述代码段,我们可以看到主控制器如何通过`FXMLLoader`和`setChildController`方法来管理子控制器。每个子控制器的实例可能在FXML加载过程中被注入到主控制器中。 #### 总结 本教程为JavaFX的使用者提供了一种结构化使用选项卡组件的方法。它通过将复杂界面分解为多个独立的FXML文件和对应的控制器类,提供了清晰的代码组织和模块化设计。同时,它还演示了如何在JavaFX中实现高度的组件交互和复杂的用户界面逻辑。通过学习本教程,JavaFX开发者将能够创建更加动态和交互性强的桌面应用程序。

相关推荐

filetype

C:\Users\86180\.jdks\openjdk-24.0.1\bin\java.exe -Dmaven.multiModuleProjectDirectory=C:\Users\86180\IdeaProjects\javafx -Djansi.passthrough=true -Dmaven.home=C:\Users\86180\.m2\wrapper\dists\apache-maven-3.8.5-bin\5i5jha092a3i37g0paqnfr15e0\apache-maven-3.8.5 -Dclassworlds.conf=C:\Users\86180\.m2\wrapper\dists\apache-maven-3.8.5-bin\5i5jha092a3i37g0paqnfr15e0\apache-maven-3.8.5\bin\m2.conf "-Dmaven.ext.class.path=C:\Users\86180\AppData\Local\Programs\IntelliJ IDEA Ultimate 2025.1.2\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Users\86180\AppData\Local\Programs\IntelliJ IDEA Ultimate 2025.1.2\lib\idea_rt.jar=62746" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\86180\.m2\wrapper\dists\apache-maven-3.8.5-bin\5i5jha092a3i37g0paqnfr15e0\apache-maven-3.8.5\boot\plexus-classworlds-2.6.0.jar;C:\Users\86180\.m2\wrapper\dists\apache-maven-3.8.5-bin\5i5jha092a3i37g0paqnfr15e0\apache-maven-3.8.5\boot\plexus-classworlds.license org.codehaus.classworlds.Launcher -Didea.version=2025.1.2 clean javafx:run WARNING: A restricted method in java.lang.System has been called WARNING: java.lang.System::load has been called by org.fusesource.jansi.internal.JansiLoader in an unnamed module (file:/C:/Users/86180/.m2/wrapper/dists/apache-maven-3.8.5-bin/5i5jha092a3i37g0paqnfr15e0/apache-maven-3.8.5/lib/jansi-2.4.0.jar) WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module WARNING: Restricted methods will be blocked in a future release unless native access is enabled WARNING: A terminally deprecated method in sun.misc.Unsafe has been called WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper (file:/C:/Users/86180/.m2/wrapper/dists/apache-maven-3.8.5-bin/5i5jha092a3i37g0paqnfr15e0/apache-maven-3.8.5/lib/guava-25.1-android.jar) WARNING: Please consider reporting this to the maintainers of class com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release [INFO] Scanning for projects... [INFO] [INFO] ---------------------< com.example:javafx-project >--------------------- [INFO] Building JavaFX 停车场管理系统 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ javafx-project --- [INFO] Deleting C:\Users\86180\IdeaProjects\javafx\target [INFO] [INFO] >>> javafx-maven-plugin:0.0.8:run (default-cli) > process-classes @ javafx-project >>> [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javafx-project --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 6 resources [INFO] [INFO] --- maven-compiler-plugin:3.13.0:compile (default-compile) @ javafx-project --- [INFO] Recompiling the module because of changed source code. [INFO] Compiling 11 source files with javac [debug release 24 module-path] to target\classes [INFO] [INFO] <<< javafx-maven-plugin:0.0.8:run (default-cli) < process-classes @ javafx-project <<< [INFO] [INFO] [INFO] --- javafx-maven-plugin:0.0.8:run (default-cli) @ javafx-project --- [WARNING] Module name not found in <mainClass>. Module name will be assumed from module-info.java 6�� 15, 2025 5:27:58 ���� dao.VehicleDAO <init> ����: δ�ҵ�MySQL JDBC��������ȷ����������� java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:463) at java.base/java.lang.Class.forName(Class.java:454) at [email protected]/dao.VehicleDAO.<init>(VehicleDAO.java:33) at [email protected]/service.ParkingService.<init>(ParkingService.java:17) at [email protected]/view.controller.MainController.initialize(MainController.java:47) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:65) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at javafx.base@24/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:112) at javafx.fxml@24/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:78) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2658) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2533) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3304) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3264) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3235) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3211) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3191) at javafx.fxml@24/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3186) at [email protected]/view.Main.start(Main.java:16) at javafx.graphics@24/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$7(LauncherImpl.java:840) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$5(PlatformImpl.java:444) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419) at javafx.graphics@24/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication.lambda$runLoop$0(WinApplication.java:168) at java.base/java.lang.Thread.run(Thread.java:1447) 6�� 15, 2025 5:27:58 ���� dao.VehicleDAO getConnection ��Ϣ: �������ӵ�MySQL���ݿ�: jdbc:mysql://localhost:3306/parking_system?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai 6�� 15, 2025 5:27:58 ���� dao.VehicleDAO getConnection ����: MySQL���ݿ�����ʧ�� java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/parking_system?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:638) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:199) at [email protected]/dao.VehicleDAO.getConnection(VehicleDAO.java:45) at [email protected]/dao.VehicleDAO.selectAllVehicles(VehicleDAO.java:122) at [email protected]/service.ParkingService.getAllVehicles(ParkingService.java:76) at [email protected]/view.controller.MainController.loadVehicleData(MainController.java:100) at [email protected]/view.controller.MainController.initialize(MainController.java:92) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:65) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at javafx.base@24/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:112) at javafx.fxml@24/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:78) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2658) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2533) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3304) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3264) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3235) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3211) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3191) at javafx.fxml@24/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3186) at [email protected]/view.Main.start(Main.java:16) at javafx.graphics@24/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$7(LauncherImpl.java:840) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$5(PlatformImpl.java:444) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419) at javafx.graphics@24/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication.lambda$runLoop$0(WinApplication.java:168) at java.base/java.lang.Thread.run(Thread.java:1447) 6�� 15, 2025 5:27:58 ���� dao.VehicleDAO getConnection ����: �������: 0 6�� 15, 2025 5:27:58 ���� dao.VehicleDAO getConnection ����: SQL״̬: 08001 6�� 15, 2025 5:27:58 ���� dao.VehicleDAO getConnection ����: ������Ϣ: No suitable driver found for jdbc:mysql://localhost:3306/parking_system?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai WARNING: A terminally deprecated method in sun.misc.Unsafe has been called WARNING: sun.misc.Unsafe::allocateMemory has been called by com.sun.marlin.OffHeapArray (file:/C:/Users/86180/.m2/repository/org/openjfx/javafx-graphics/24/javafx-graphics-24-win.jar) WARNING: Please consider reporting this to the maintainers of class com.sun.marlin.OffHeapArray WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release java.lang.NullPointerException: Cannot invoke "java.sql.Connection.prepareStatement(String)" because "connection" is null at [email protected]/dao.VehicleDAO.selectAllVehicles(VehicleDAO.java:123) at [email protected]/service.ParkingService.getAllVehicles(ParkingService.java:76) at [email protected]/view.controller.MainController.loadVehicleData(MainController.java:100) at [email protected]/view.controller.MainController.initialize(MainController.java:92) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:65) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at javafx.base@24/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:112) at javafx.fxml@24/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:78) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2658) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2533) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3304) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3264) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3235) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3211) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3191) at javafx.fxml@24/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3186) at [email protected]/view.Main.start(Main.java:16) at javafx.graphics@24/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$7(LauncherImpl.java:840) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$5(PlatformImpl.java:444) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419) at javafx.graphics@24/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication.lambda$runLoop$0(WinApplication.java:168) at java.base/java.lang.Thread.run(Thread.java:1447) 6�� 15, 2025 5:28:02 ���� dao.VehicleDAO getConnection ��Ϣ: �������ӵ�MySQL���ݿ�: jdbc:mysql://localhost:3306/parking_system?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai 6�� 15, 2025 5:28:02 ���� dao.VehicleDAO getConnection ����: MySQL���ݿ�����ʧ�� java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/parking_system?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:638) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:199) at [email protected]/dao.VehicleDAO.getConnection(VehicleDAO.java:45) at [email protected]/dao.VehicleDAO.selectAllVehicles(VehicleDAO.java:122) at [email protected]/service.ParkingService.getAllVehicles(ParkingService.java:76) at [email protected]/service.ParkingService.getVehicleCount(ParkingService.java:111) at [email protected]/view.controller.MainController.updateStatistics(MainController.java:112) at [email protected]/view.controller.MainController.initialize(MainController.java:93) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:65) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at javafx.base@24/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:112) at javafx.fxml@24/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:78) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2658) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2533) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3304) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3264) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3235) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3211) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3191) at javafx.fxml@24/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3186) at [email protected]/view.Main.start(Main.java:16) at javafx.graphics@24/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$7(LauncherImpl.java:840) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$5(PlatformImpl.java:444) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419) at javafx.graphics@24/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication.lambda$runLoop$0(WinApplication.java:168) at java.base/java.lang.Thread.run(Thread.java:1447) 6�� 15, 2025 5:28:02 ���� dao.VehicleDAO getConnection ����: �������: 0 6�� 15, 2025 5:28:02 ���� dao.VehicleDAO getConnection ����: SQL״̬: 08001 6�� 15, 2025 5:28:02 ���� dao.VehicleDAO getConnection ����: ������Ϣ: No suitable driver found for jdbc:mysql://localhost:3306/parking_system?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai java.lang.NullPointerException: Cannot invoke "java.sql.Connection.prepareStatement(String)" because "connection" is null at [email protected]/dao.VehicleDAO.selectAllVehicles(VehicleDAO.java:123) at [email protected]/service.ParkingService.getAllVehicles(ParkingService.java:76) at [email protected]/service.ParkingService.getVehicleCount(ParkingService.java:111) at [email protected]/view.controller.MainController.updateStatistics(MainController.java:112) at [email protected]/view.controller.MainController.initialize(MainController.java:93) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:65) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at javafx.base@24/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:112) at javafx.fxml@24/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:78) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2658) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2533) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3304) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3264) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3235) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3211) at javafx.fxml@24/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3191) at javafx.fxml@24/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3186) at [email protected]/view.Main.start(Main.java:16) at javafx.graphics@24/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$7(LauncherImpl.java:840) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$5(PlatformImpl.java:444) at javafx.graphics@24/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419) at javafx.graphics@24/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics@24/com.sun.glass.ui.win.WinApplication.lambda$runLoop$0(WinApplication.java:168) at java.base/java.lang.Thread.run(Thread.java:1447) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 13.126 s [INFO] Finished at: 2025-06-15T17:28:06+08:00 [INFO] ------------------------------------------------------------------------ 进程已结束,退出代码为 0

filetype

javafx C:\Users\86178\.jdks\openjdk-23.0.2\bin\java.exe --module-path C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib --add-modules javafx.controls,javafx.fxml "-javaagent:D:\javakaifa\IntelliJ IDEA Community Edition 2024.2.4\lib\idea_rt.jar=51643:D:\javakaifa\IntelliJ IDEA Community Edition 2024.2.4\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath D:\javakaifa\tank\out\production\tank;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx-swt.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.base.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.controls.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.fxml.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.graphics.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.media.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.swing.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.web.jar Main Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at [email protected]/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1863) at [email protected]/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1731) at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232) at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189) at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.di

filetype

C:\Users\86178\.jdks\openjdk-23.0.2\bin\java.exe --module-path C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib --add-modules javafx.controls,javafx.fxml "-javaagent:D:\javakaifa\IntelliJ IDEA Community Edition 2024.2.4\lib\idea_rt.jar=51794:D:\javakaifa\IntelliJ IDEA Community Edition 2024.2.4\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath D:\javakaifa\tt\out\production\tt;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx-swt.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.base.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.controls.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.fxml.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.graphics.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.media.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.swing.jar;C:\Users\86178\Downloads\openjfx-23.0.2_windows-x64_bin-sdk\javafx-sdk-23.0.2\lib\javafx.web.jar ql.tank.Main Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at [email protected]/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1863) at [email protected]/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1731) at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232) at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189) at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.dispa