Git Product home page Git Product logo

javafx-examples's Introduction

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

javafx-examples's People

Contributors

danielpeintner avatar hosseinmp76 avatar jjenkov avatar markhm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.