Need help with springboot-javafx-app-demo?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

realpdai
240 Stars 111 Forks MIT License 8 Commits 4 Opened issues

Description

springboot+Javafx 桌面应用

Services available

!
?

Need anything else?

Contributors list

# 279,331
CSS
Java
4 commits

springboot-javafx-app-demo

Spring Boot - JavaFX 2.0应用

很多人对Java开发native程序第一反应还停留在暗灰色单一风格的Java GUI界面,开发方式还停留在AWT或者Swing。本文主要基于SpringBoot和JavaFX开发一个Demo给你展示Java Native应用可以做到什么样的程度。当然JavaFX 2.0没有流行起来也是有原因的,而且目前native的选择很多,前端是个框架都会搞个native... @pdai

最全的Java后端知识体系 https://www.pdai.tech, 每天更新中...

技术背景 - Java 8的新特性之JavaFX2.0

全新现代主题:Modena

新的Modena主题来替换原来的Caspian主题。不过在Application的start()方法中,可以通过setUserAgentStylesheet(STYLESHEET_CASPIAN)来继续使用Caspian主题。

参考http://fxexperience.com/2013/03/modena-theme-update/

用于 CSS 结构的公共 API

  • CSS 样式设置是 JavaFX 的一项主要特性
  • CSS 已专门在私有 API 中实现(com.sun.javafx.css 软件包)
  • 多种工具(例如 Scene Builder)需要 CSS 公共 API
  • 开发人员将能够定义自定义 CSS 样式

WebView 增强功能

  • Nashorn JavaScript 引擎 https://blogs.oracle.com/nashorn/entry/openforbusiness
  • WebSocket http://javafx-jira.kenai.com/browse/RT-14947
  • Web Workers http://javafx-jira.kenai.com/browse/RT-9782

JavaFX Scene Builder 2.0

可视化工具,加速JavaFX图形界面的开发:

JavaFX Scene Builder如同NetBeans一般,通过拖拽的方式配置界面,待完成界面之後,保存为FXML格式文件,此文件以XML描述物件配置,再交由JavaFX程式处理,因此可減少直接以JavaFX编写界面的困難度。

JavaFX Scene Builder 2.0新增JavaFX Theme预览功能,菜单「Preview」→「JavaFX Theme」选择不同的主題,包括:

  • Modena (FX8).
  • Modena Touch (FX8).
  • Modena High Contrast – Black on White (FX8).
  • Modena High Contrast – White on Black (FX8).
  • Modena High Contrast – Yellow on Black (FX8).
  • Caspian (FX2).
  • Caspian Embedded (FX2).
  • Caspian Embedded QVGA (FX2).

JavaFX 3D

在JavaFX8中提供了3D图像处理API,包括Shape3D (Box, Cylinder, MeshView, Sphere子类),SubScene, Material, PickResult, LightBase (AmbientLight 和PointLight子类),SceneAntialiasing等。Camera类也得到了更新。从JavaDoc中可以找到更多信息。

富文本

强化了富文本的支持

TreeTableView

TreeTable支持

日期控件DatePicker

增加日期控件

Spring Boot+JavaFX2 Demo介绍

程序加载 - Loader

和WEB一样风格的GUI

对话框 - Popup

Web应用嵌入 - Webview

多种主题切换 - Theme

消息及配置悬浮框 - Message/Configuration...

全屏最大化最小化 - FullScreen/Max/Min/Close

包括全屏是基于JavaFX的一个组件,不是原生。

如何部署

收到几个开发问如何进行运行和部署,统一回复下:

  • 安装jar到本地的maven库

具体执行maven安装的脚本如下(这里D:\git\github\springboot-javafx-app-demo是我本地的项目目录,需要改成你自己的):

mvn install:install-file -DgroupId=gn -DartifactId=GNCalendar -Dversion=v1.0 -Dpackaging=jar -Dfile=D:\git\github\springboot-javafx-app-demo\lib\GNCalendar-1.0-alpha.jar

mvn install:install-file -DgroupId=gn -DartifactId=GNButton -Dversion=v1.1.0 -Dpackaging=jar -Dfile=D:\git\github\springboot-javafx-app-demo\lib\GNButton-1.1.0.jar

mvn install:install-file -DgroupId=gn -DartifactId=GNCarousel -Dversion=v2.1.5 -Dpackaging=jar -Dfile=D:\git\github\springboot-javafx-app-demo\lib\GNCarousel-2.1.5.jar

mvn install:install-file -DgroupId=gn -DartifactId=GNDecorator -Dversion=v2.1.2-alpha -Dpackaging=jar -Dfile=D:\git\github\springboot-javafx-app-demo\lib\GNDecorator-2.1.2-alpha.jar

mvn install:install-file -DgroupId=gn -DartifactId=GNAvatarView -Dversion=v1.0-rc -Dpackaging=jar -Dfile=D:\git\github\springboot-javafx-app-demo\lib\GNAvatarView-1.0-rc.jar

在这里执行:

  • 编译的maven插件

  • pom.xml如下
    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.1.4.RELEASE
         
    
    com.example
    spring-fx-app
    0.0.1-SNAPSHOT
    spring-fx-app
    Demo project for Spring Boot

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-starter</artifactid>
    </dependency>

    <!-- mvn install:install-file -DgroupId=gn -DartifactId=GNAvatarView -Dversion=v1.0-rc -Dpackaging=jar -Dfile=D:\git\github\springb

oot-javafx-app-demo\lib\GNAvatarView-1.0-rc.jar --> gn GNAvatarView v1.0-rc gn GNButton v1.1.0 gn GNCalendar v1.0 gn GNCarousel v2.1.5 gn GNDecorator v2.1.2-alpha

    <!-- https://mvnrepository.com/artifact/io.github.typhon0/AnimateFX -->
    <dependency>
        <groupid>io.github.typhon0</groupid>
        <artifactid>AnimateFX</artifactid>
        <version>1.2.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.controlsfx/controlsfx -->
    <dependency>
        <groupid>org.controlsfx</groupid>
        <artifactid>controlsfx</artifactid>
        <version>8.40.14</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/de.jensd/fontawesomefx -->
    <dependency>
        <groupid>de.jensd</groupid>
        <artifactid>fontawesomefx</artifactid>
        <version>8.9</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.jfoenix/jfoenix -->
    <dependency>
        <groupid>com.jfoenix</groupid>
        <artifactid>jfoenix</artifactid>
        <version>8.0.7</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/eu.hansolo/tilesfx -->
    <dependency>
        <groupid>eu.hansolo</groupid>
        <artifactid>tilesfx</artifactid>
        <version>1.6.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/eu.hansolo/colors -->
    <dependency>
        <groupid>eu.hansolo</groupid>
        <artifactid>colors</artifactid>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-starter-test</artifactid>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
            <plugin>
                <groupid>com.zenjava</groupid>
                <artifactid>javafx-maven-plugin</artifactid>
                <version>8.8.3</version>
                <configuration>
                    <vendor>pdai</vendor>
                    <mainclass>com.pdai.javafx.app.SpringFxAppApplication</mainclass>
                    <allpermissions>true</allpermissions>
                </configuration>
            </plugin>
    </plugins>
</build>
  • 以jar运行为例:
D:\git\github\springboot-javafx-app-demo>java -jar D:\git\github\springboot-javafx-app-demo\target\jfx\native\spring-fx-app-0.0.1-SNAPSHOT\app\spring-fx-app-0.0.1-SNAPSHOT-jfx.jar

. __ _ __ _ _ /\ / _'_ __ _ ()_ __ __ _ \ \ \
( ( )___ | '_ | '| | ' / ` | \ \ \
\/ __
)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||| |\, | / / / / =========||==============|__/=///_/ :: Spring Boot :: (v2.1.4.RELEASE)

2020-07-01 06:27:46.091 INFO 144952 --- [onPool-worker-1] o.s.boot.SpringApplication : Starting application on pdai with PID 144952 (started by pdai in D:\git\github\springboot-javafx-app-demo) 2020-07-01 06:27:46.099 INFO 144952 --- [onPool-worker-1] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default 2020-07-01 06:27:47.099 INFO 144952 --- [onPool-worker-1] o.s.boot.SpringApplication : Started application in 1.784 seconds (JVM running for 2.838) 2020-07-01 06:27:47.163 WARN 144952 --- [JavaFX-Launcher] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:51.932 WARN 144952 --- [JavaFX-Launcher] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:53.084 WARN 144952 --- [JavaFX-Launcher] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:54.166 WARN 144952 --- [JavaFX-Launcher] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:54.207 WARN 144952 --- [JavaFX-Launcher] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:54.263 WARN 144952 --- [JavaFX-Launcher] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:54.322 WARN 144952 --- [JavaFX-Launcher] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:56.569 WARN 144952 --- [lication Thread] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:56.590 WARN 144952 --- [lication Thread] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:56.694 WARN 144952 --- [lication Thread] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65 2020-07-01 06:27:56.707 WARN 144952 --- [lication Thread] javafx : Loading FXML document with JavaFX API of version 8.0.171 by JavaF X runtime of version 8.0.65

示例代码

@See https://github.com/realpdai/springboot-javafx-app-demo

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.