1. Local environmental structures
Installation JDK1.8, please refer to the online installation tutorial
Installation IntelliJ IDEA, please refer to the online installation tutorial
2. Environmental ready to create a project
Select Maven Project Type
On how to create a Maven project, please refer to the Internet
3. After the project is created, add pom-dependent
Add the following dependencies in the project pom.xml file
<dependencies>
<! - package graphics and multimedia processing tools set ->
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>8.0.8</version>
</dependency>
<! - Fonts icon ->
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
<version>8.9</version>
</dependency>
<-! Processing json ->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<! - Test Unit ->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
4. Preparation of Hello World code, the code follows
package com.dengyunshuo.demo;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
/**
* @author dengdashuai
* @date 2019-09-03
*/
public class HelloWorld extends Application {
/**
* Start the main window
* @param primaryStage
* @throws Exception
*/
public void start(Stage primaryStage) throws Exception {
/*
* Create a label object
* The text on the label is "Hello World"
*/
Label label = new Label("Hello World");
// set the label position in the parent container - the right home
label.setAlignment (Pos.CENTER_RIGHT);
/*
* Create a scene object
* Scene is a label that contains content
* Scene width and height are 500
*/
Scene scene = new Scene(label,500,500);
// put the scene into the main window
primaryStage.setScene(scene);
// display window
primaryStage.show();
}
/**
* Main entry
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// Start the application
HelloWorld.launch(args);
}
}
5. After starting the application, the following theme
6. A simple Hello World has been completed, this chapter is over, the next section we will upgrade this Hello World, so stay tuned Oh!