How to use JavaFX and Jfoenix
This article mainly introduces how to use JavaFX and Jfoenix, the article is very detailed, has a certain reference value, interested friends must read it!
1. Local environment building
To install JDK1.8, please refer to the website for installation tutorials
To install IntelliJ IDEA, please refer to the website for installation tutorials
two。 When the environment is ready, create the project
Select Maven for project type
For information on how to create a Maven project, please refer to the website.
3. After the project is created, add pom dependencies
Add the following dependencies to the pom.xml file in the project
Com.jfoenix
Jfoenix
8.0.8
De.jensd
Fontawesomefx
8.9
Com.alibaba
Fastjson
1.2.58
Junit
Junit
3.8.1
Test
4. Write the Hello World code as 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 {
/ * *
* launch 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 location of the label in the parent container-on the right
Label.setAlignment (Pos.CENTER_RIGHT)
/ *
* create a scene object
* the content contained in the scene is a tag
* scene width and height are 500 respectively
, /
Scene scene = new Scene (label,500500)
/ / put the scene into the main window
PrimaryStage.setScene (scene)
/ / display window
PrimaryStage.show ()
}
/ * *
* main entry of the program
* @ param args
* @ throws Exception
, /
Public static void main (String [] args) throws Exception {
/ / start the application
HelloWorld.launch (args)
}
}
5. After launching the application, the screenshot is as follows
The above is all the content of the article "how to use JavaFX and Jfoenix". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!