**
- springBoot+javaFX 10分钟搭建完整的桌面应用程序
**
能媲美WPF的UI界面,用JAVA就可以实现,先推荐一下社区。https://openjfx.cn/
上干货
1.准备环境。
JDK 1.8
IDEA 2020(我的)
SceneBuilder 2.0
打开IDEA->配置SceneBuilder 2.0 可以看看这篇文章 https://www.cnblogs.com/shiliye/p/12952545.html
创建springboot+maven 开箱即用项目
依赖:这2个就够了
org.springframework.boot
spring-boot-starter
<dependency>
<groupId>de.roskenet</groupId>
<artifactId>springboot-javafx-support</artifactId>
<version>2.1.6</version>
</dependency>
打包: 一.msi结尾
org.springframework.boot
spring-boot-maven-plugin
com.zenjava
javafx-maven-plugin
8.8.3
com.你的javaFX主类
打包app名称
你项目groupId
true
p
r
o
j
e
c
t
.
b
a
s
e
d
i
r
/
p
a
t
h
/
t
o
/
i
c
o
n
.
i
c
o
<
/
d
e
p
l
o
y
D
i
r
>
<
b
u
n
d
l
e
A
r
g
u
m
e
n
t
s
>
<
!
−
−
打包的图标
−
−
>
<
i
c
o
n
>
{project.basedir}/path/to/icon.ico</deployDir> <bundleArguments> <!--打包的图标--> <icon>
project.basedir/path/to/icon.ico</deployDir><bundleArguments><!−−打包的图标−−><icon>{basedir}/src/main/resources/image/app.ico
true
目录结构
主类:
@SpringBootApplication
public class XXXApplication extends AbstractJavaFxApplicationSupport {
public static void main(String[] args) {
launch(XXXApplication.class, IndexView.class, new SplashScreenCustom(), args);
}
@Override
public void start(Stage stage) throws Exception {
stage.setTitle("XXX管理系统");
super.start(stage);
}
@Override
public Collection<Image> loadDefaultIcons() {
return Arrays.asList(new Image(this.getClass().getClassLoader().getResource("image/log.jpg").toExternalForm()));
}
}
程序启动动画配置类SplashScreenCustom
public class SplashScreenCustom extends SplashScreen {
@Override
public Parent getParent() { // 在这里可以设置闪屏窗口大小,默认图片大小
return super.getParent();
}
@Override
public boolean visible() { // 是否显示闪屏,默认显示
return super.visible();
}
@Override
public String getImagePath() {
return "/image/start.gif";
}
}
创建fxml文件,右击用SceneBuilder 2.0打开
拖拉拽完成想要窗口布局这部分可以去社区学习
创建对应的view对应好fxml的路径
创建对应的controller
双击jfx:native 打包
然后就能找到安装包了
当然这个安装包自带jre环境哦
就这些了,沟通加我qq:1095591682