{"id":15056264,"url":"https://github.com/yoep/spring-boot-starter-javafx","last_synced_at":"2025-07-27T19:40:34.703Z","repository":{"id":57724352,"uuid":"225129185","full_name":"yoep/spring-boot-starter-javafx","owner":"yoep","description":"Spring Boot starter for JavaFX","archived":false,"fork":false,"pushed_at":"2024-04-21T20:40:13.000Z","size":513,"stargazers_count":32,"open_issues_count":2,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T04:07:07.754Z","etag":null,"topics":["javafx","spring","spring-boot-starter"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-01T08:27:39.000Z","updated_at":"2025-02-14T11:37:38.000Z","dependencies_parsed_at":"2024-01-13T21:28:11.202Z","dependency_job_id":"19bbf052-2a2e-4a14-81dc-5dae41484a1e","html_url":"https://github.com/yoep/spring-boot-starter-javafx","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoep%2Fspring-boot-starter-javafx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoep%2Fspring-boot-starter-javafx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoep%2Fspring-boot-starter-javafx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoep%2Fspring-boot-starter-javafx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoep","download_url":"https://codeload.github.com/yoep/spring-boot-starter-javafx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154984,"owners_count":21056543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javafx","spring","spring-boot-starter"],"created_at":"2024-09-24T21:49:37.719Z","updated_at":"2025-04-10T04:07:14.288Z","avatar_url":"https://github.com/yoep.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Boot JavaFX starter\n\nSpring Boot starter for easy integration with JavaFX.\nThis library provides easy integration with JavaFX as well as additional helpers for \nloading \u0026 managing JavaFX views in Spring.\n\n## Maven\n\nThe library is available in the maven central repository and can be used by adding:\n\n_Spring Boot 3.X_\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.yoep\u003c/groupId\u003e\n  \u003cartifactId\u003espring-boot-starter-javafx\u003c/artifactId\u003e\n  \u003cversion\u003e2.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n_Spring Boot 2.X_\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.yoep\u003c/groupId\u003e\n  \u003cartifactId\u003espring-boot-starter-javafx\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.12\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Requirements\n\n### Version 1.0.0+\n\nThis is the legacy version of the library which requires Spring Boot 2+ and Java 8+.\n\n- Spring Boot 2+\n- Java 8+\n\n### Version 2.0.0+\n\nThis is the new major version of the library which requires Spring Boot 3+ and Java 17+.\n\n- Spring Boot 3+\n- Java 17+\n\n## Usage\n\nCreate a class which extends `SpringJavaFXApplication` and launch the JavaFX application from this class.\n\n_main entry example_\n```java\n@SpringBootApplication\npublic class MySpringApplication extends SpringJavaFXApplication {\n\n    public static void main(String[] args) {                \n        launch(MySpringApplication.class, args);\n    }\n    \n    @Override\n    public void start(Stage primaryStage) throws Exception {\n        super.start(primaryStage);\n        \n        // YOUR CODE ON STARTUP HERE\n    }\n}\n```\n\nCreate a `ResourceBundle` bean which can be used by JavaFX within `.fxml` files.\n\n_resource bundle example_\n```java\n@Configuration\npublic class LanguageConfig {\n    @Bean\n    public ResourceBundleMessageSource messageSource() {\n        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();\n        messageSource.setBasenames(\"lang/example\");\n        return messageSource;\n    }\n}\n```\n\n### Borderless stage\n\nYou can create a borderless (undecorated) stage which is still resizable \nand draggable by using the `BorderlessStage` class.\n\nThis functionality can also be achieved on the primary stage by using\nthe `BorderlessStageWrapper` as follows:\n\n```java\n\n@SpringBootApplication\npublic class MySpringApplication extends SpringJavaFXApplication {    \n    @Override\n    public void start(Stage stage) throws Exception {\n        var myBorderlessStage = new BorderlessStageWrapper(stage);\n        super.start(stage);\n        \n        // set the height of the header\n        // this height is used within the BorderlessStage\n        // to drag the window around\n        myBorderlessStage.setHeader(20);\n        // set the virtual border of the BorderlessStage\n        // this width is used to determine when the user can grab \n        // the non-existing border to resize the borderless stage\n        myBorderlessStage.setResizeBorder(2);\n    }\n}\n```\n\n### View controllers\n\nUse the following stereotype to define a view controller.\nThis is not required as the library will use any bean that is known within the \n`ApplicationContext` to bind them to views.\n\n```java\n@ViewController\npublic class MyViewController {\n}\n```\n\n### Loading views\n\nThere are 2 options when loading views, automatic controller selection through beans\nor manually defining the controller that needs to be used by JavaFX.\n\n- Automatically use a controller from the `ApplicationContext`.\n\n```java\nprivate class Example {\n    private ViewLoader viewLoader;\n    \n    private void loadView() {\n        viewLoader.load(\"my-view-file.fxml\");\n    }\n}\n```\n\n- Define a controller which needs to be used in the view.\n\n```java\nprivate class Example {\n    private ViewLoader viewLoader;\n    \n    private void loadView() {\n        ViewController controller = new ViewController();\n        \n        viewLoader.load(\"my-view-file.fxml\", controller);\n    }\n}\n```\n\n## FAT jar packaging\n\nIt is **recommended to not use** the `spring-boot-maven-plugin` if you want to package the JavaFX application into a fat jar.\nThe reason behind this, is that the plugin will break JavaFX due to the JAR layout that is used by the plugin.\n\nFor creating fat jar packages, use the `maven-shade-plugin` instead.\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n    \u003cartifactId\u003emaven-shade-plugin\u003c/artifactId\u003e\n    \u003cconfiguration\u003e\n        \u003ckeepDependenciesWithProvidedScope\u003efalse\u003c/keepDependenciesWithProvidedScope\u003e\n    \u003c/configuration\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cphase\u003epackage\u003c/phase\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003eshade\u003c/goal\u003e\n            \u003c/goals\u003e\n            \u003cconfiguration\u003e\n                \u003ctransformers\u003e\n                    \u003ctransformer implementation=\"org.apache.maven.plugins.shade.resource.AppendingTransformer\"\u003e\n                        \u003cresource\u003eMETA-INF/spring.handlers\u003c/resource\u003e\n                    \u003c/transformer\u003e\n                    \u003ctransformer implementation=\"org.springframework.boot.maven.PropertiesMergingResourceTransformer\"\u003e\n                        \u003cresource\u003eMETA-INF/spring.factories\u003c/resource\u003e\n                    \u003c/transformer\u003e\n                    \u003ctransformer implementation=\"org.apache.maven.plugins.shade.resource.AppendingTransformer\"\u003e\n                        \u003cresource\u003eMETA-INF/spring.schemas\u003c/resource\u003e\n                    \u003c/transformer\u003e\n                    \u003ctransformer implementation=\"org.apache.maven.plugins.shade.resource.ServicesResourceTransformer\"/\u003e\n                    \u003ctransformer implementation=\"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer\"\u003e\n                        \u003cmainClass\u003e${start-class}\u003c/mainClass\u003e\n                    \u003c/transformer\u003e\n                \u003c/transformers\u003e\n            \u003c/configuration\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n\u003c/plugin\u003e\n```\n    \n## IntelliJ IDEA\n\nIntelliJ adds by default the `javafx.base` and `javafx.graphics` to the modules of Java 9+.\nThis might be causing issues in Java 9 and above, as the `javafx.controls` and `javafx.fxml` are \nmissing from the modules causing an `IllegalAccessException` when trying to run the application.\n\nAdd the following options to the `VM Options` in the run configuration of IntelliJ to fix this issue. \n\n    -p \"\u003cPATH TO JAVAFX SDK\u003e\\lib\" --add-modules javafx.controls,javafx.fxml,javafx.swing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoep%2Fspring-boot-starter-javafx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoep%2Fspring-boot-starter-javafx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoep%2Fspring-boot-starter-javafx/lists"}