Skip to content
プロジェクト

jjenkov/javafx-examples

GitHubで見る

概要

JavaFXの基本機能から高度な機能までを紹介する、豊富なサンプル集です。

学習・教育

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
-2
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

JavaFX Examples

This repository contains a growing collection of JavaFX examples. So far this GitHub repository contains 76 examples. I have plans to add lots more examples in the future, so make sure you star this repository for future reference ;-)

The lists of examples is found here:

JavaFX Tutorial

The examples come from my JavaFX tutorial series: JavaFX Tutorial.

Java + JavaFX Version Used

In general the examples in this repository will attempt to use the latest version of Java and JavaFX. For now the examples are tested with Java 14 and JavaFX 14 (yes, 15 + 15 are latest - will update soon!).

Running the Examples

There are 3 options to run the examples.

  • Using your IDE (IntelliJ IDEA / Eclipse / Netbeans)
  • Using Maven - passing main class to run on the command line
  • Using gradle - passing main class to run on the command line
  • Using Maven - configuring the main class inside the pom.xml

Some of these are covered in more detail below.

Run the Examples in IntelliJ Idea(needs pre-downloaded javafx modules)

To run the examples from within IntelliJ IDEA you must first create a new project in IntelliJ, and set the root directory to the directory into which you have cloned this Git repository.

Second, you must download JavaFX and unzip the distribution to some directory.

Third, you must add all the JAR files found in the "lib" directory to your project's classpath.

Fourth, you must create a run configuration for the example class you want to run. Add the following JVM args to that run configuration:

--module-path C:\data\downloads\javafx\javafx-sdk-14\lib --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web

Make sure that the --module-path points to the directory you unzipped your downloaded JavaFX distribution to (meaning the "lib" dir within that JavaFX distribution dir - as shown above).

Run in IDE - alternative

Instead of creating run configuration for each example class you can create a run configuration for the ExampleRunner class(based on maven or gradle nature. Both are supported using wrappers so you don't need to have any of them on you system and you can choose to use the one you prefer), and then from inside the ExampleRunner class, call the example class you want to run - by changing the main() method inside the ExampleRunner class. For instance, add the following line to the ExampleRunner class main() method and then run ExampleRunner main

ButtonExample.main(args);

Run via Maven - Passing Main Class as Argument to Maven

You can use maven and pass the example class you want to add. for example to run WebViewExample you can run

./mvnw compile exec:java -Dexec.args="com.jenkov.javafx.webview.WebViewExample"

Run via Gradle - Passing Main Class as Argument to Gradle

You can use gradle and pass the example class you want to add. for example to run WebViewExample you can run

./gradlew run --args="com.jenkov.javafx.webview.WebViewExample"

Run via Maven

You can use Maven and edit the pom.xml file and change "mainClass" of openjfx plugin configuration and select the example you want then run

./mvnw clean javafx:run

Suggestions

If you have any suggestions for missing examples, create a GitHub issue in this repo, and / or ping me on Twitter (@jjenkov) or LinkedIn (Jakob Jenkov).

JavaFX Basic Examples

JavaFX Advanced Examples

関連プロジェクトを探す

読み込み中…