JavaFx | 您所在的位置:网站首页 › fhx插件 › JavaFx |
JavaFx-创建一个简单的JavaFx maven项目
1、环境基础:jdk1.8、 idea、 maven3.6.3 2、 使用idea创建一个空的maven项目,填写好基本的项目信息就可以了。
3、创建好的maven项目里面空空如也,正是我们想要的,之后在java目录里创建必要的目录和java 类就可以了,例如下面的简单代码 package com.mrx; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application { public static void main(String[] args) { launch(args); } public void start(Stage primaryStage) throws Exception { BorderPane root = new BorderPane(); Label label = new Label("Hello World"); root.setCenter(label); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.setWidth(800); primaryStage.setHeight(600); primaryStage.setTitle("JavaFx Demo"); primaryStage.show(); } }4、运行之后就能显示窗口了 5、程序如果需要引入第三方依赖,直接在pom中引入即可,例如程序需要引入poi、commons-lang3、fastjson、hutool等。 4.0.0 com.mrx javafx-maven-demo 1.0-SNAPSHOT UTF-8 1.8 1.8 org.apache.poi poi-ooxml 4.1.2 org.apache.commons commons-lang3 3.12.0 com.alibaba fastjson 1.2.80 cn.hutool hutool-all 5.8.0.M4小尾巴~~ 只要有积累,就会有进步 |
CopyRight 2018-2019 实验室设备网 版权所有 |