# jtool-plus **Repository Path**: ccbx/jtool-plus ## Basic Information - **Project Name**: jtool-plus - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-13 - **Last Updated**: 2026-04-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # JTool Plus Modern JavaFX Framework with Spring Integration Support ## 项目简介 JTool Plus 是一个基于 JavaFX 的现代化桌面应用开发框架,提供完整的窗口生命周期管理、事件驱动架构、国际化支持和 MVVM 模式。框架采用模块化设计,核心模块与 Spring Boot 无关,可独立使用;同时提供 Spring Boot 集成模块,实现依赖注入和自动配置的无缝接入。 ## 模块架构 ``` jtool-plus (父工程) ├── jfx 核心框架模块 — 窗口生命周期、事件系统、国际化、流畅 UI 构建 └── jfx-spring Spring 集成模块 — Spring Boot 自动配置、Bean 工厂桥接 ``` | 模块 | 说明 | 详细文档 | |------|------|----------| | **jfx** | JavaFX 核心框架,提供窗口生命周期管理、事件总线、国际化、MVVM 基础设施和流畅 UI 构建 API | [jfx/README.md](jfx/README.md) | | **jfx-spring** | Spring Boot 集成层,提供自动配置、Spring 容器管理的 Bean 工厂和外部化配置支持 | [jfx-spring/README.md](jfx-spring/README.md) | 模块依赖关系:`jfx-spring` → `jfx`(jfx-spring 依赖 jfx 核心模块) ## 技术栈 | 技术 | 版本 | 用途 | |------|------|------| | Java | 21 | 运行时 | | JavaFX | 21 | UI 框架 | | Spring Boot | 3.2.5 | 依赖注入与自动配置(仅 jfx-spring) | | SLF4J | 2.0.12 | 日志门面 | | Logback | 1.4.14 | 日志实现 | | Maven | — | 构建工具 | | JUnit 5 | 5.10.2 | 单元测试 | ## 核心特性 - **生命周期驱动** — 8 阶段窗口生命周期(onInit → buildUI → beforeShow → onShow → allowClose → onClose → onHide → onDestroy) - **事件驱动架构** — 类型安全的全局事件总线,支持同步/异步派发和窗口级自动订阅管理 - **双作用域窗口** — SINGLETON(单例复用)和 PROTOTYPE(一次性)两种窗口策略 - **注解驱动配置** — `@JfxWindow` + `@StageConfig` + `@SceneConfig` 声明式窗口配置 - **国际化支持** — 基于 ResourceBundle 的 i18n,支持运行时语言切换和事件通知 - **流畅 UI 构建** — Builder 模式的 JavaFX 组件构建 API,消除样板代码 - **MVVM 架构** — BaseViewModel 提供 JavaFX Property 工厂方法 - **Spring 集成** — 可选的 Spring Boot 自动配置,支持依赖注入和外部化配置 - **线程安全** — 全面使用 volatile、ConcurrentHashMap、CopyOnWriteArrayList 等并发机制 ## 快速开始 ### 纯 JavaFX 使用 ```java @JfxWindow(title = "主窗口", stage = @StageConfig(width = 800, height = 600)) public class MainWindow extends WindowLifecycleSupport { public MainWindow() { super(ctx -> Jfx.VBox().spacing(10).padding(20).children( Jfx.label("Hello, JTool Plus!").build(), Jfx.button("点击").onClick(e -> showMessage()).build() ).build()); } } public class MyApp extends JfxApplication { @Override protected Class getMainWindowClass() { return MainWindow.class; } public static void main(String[] args) { launchApp(args, MyApp.class); } } ``` ### Spring Boot 集成使用 ```java @JfxWindow(title = "主窗口") @Component public class MainWindow extends WindowLifecycleSupport { @Autowired private UserService userService; public MainWindow() { super(ctx -> Jfx.VBox().spacing(10).padding(20).children( Jfx.label("Hello, Spring + JavaFX!").build() ).build()); } } public class MyApp extends SpringJfxApplication { @Override protected ConfigurableApplicationContext createSpringContext() { return createDefaultSpringContext(MyApp.class); } @Override protected Class getMainWindowClass() { return MainWindow.class; } public static void main(String[] args) { launchApp(args, MyApp.class); } } ``` ## 构建 ```bash mvn clean install ``` ## 项目信息 - **GroupId**: `com.jtoolplus` - **Version**: `1.0.0` - **Java 版本**: 21 - **编码**: UTF-8