Fuzio in JavaFX

This page describes how to configure a Gradle project to use Fuzio with the JavaFX GUI toolkit.

Prerequisites 

Getting the project 

The sample project described below in this guide can be found as the standalone repository on Gitee.

Configuring the Gradle project 

Repository 

Fuzio is distributed via the maven repository hosted by Jiku. Please add the following repository reference to your build.gradle.kts:

repositories {
   // The repository with Fuzio binaries.
   maven("https://jiku.mycloudrepo.io/public/repositories/releases")
}

Version variable 

We recommend to define a variable for the version of Fuzio used in the project. The following sections reference such a variable.

val fuzioVersion = "2026.1.0"

Platform 

To add Fuzio library that works on Windows, macOS, and Linux, please add the following code:

dependencies {
   implementation "tech.fuzio:fuzio-cross-platform:$fuzioVersion"
}

JavaFX 

Fuzio To use Fuzio in the JavaFX GUI of your app, please add the corresponding Fuzio dependencies as well:

dependencies {
   implementation("tech.fuzio:fuzio-javafx:$fuzioVersion")
}

For seamless JavaFX integration, we recommend using the JavaFX gradle plugin:

plugins {
    id("org.openjfx.javafxplugin") version "0.1.0"
}

Kotlin DSL 

If you develop using Kotlin, then we recommend that you to add Fuzio Kotlin DSL for the best experience.

dependencies {
   implementation("tech.fuzio:fuzio-kotlin:$fuzioVersion")
}

Gradle build file 

As the result, you should have the following build.gradle.kts:


plugins {
    java
    application
    id("org.openjfx.javafxplugin") version "0.1.0"
    kotlin("jvm") version "2.0.0"
}

val fuzioVersion = "2026.1.0"

repositories {
    mavenCentral()
    maven("https://jiku.mycloudrepo.io/public/repositories/releases")
}

dependencies {
    implementation("tech.fuzio:fuzio-cross-platform:${fuzioVersion}")
    implementation("tech.fuzio:fuzio-javafx:${fuzioVersion}")
    implementation(kotlin("stdlib-jdk8"))
    implementation("tech.fuzio:fuzio-kotlin:${fuzioVersion}")
}

javafx {
    version = "21.0.5"
    modules("javafx.controls")
}

kotlin {
    jvmToolchain(17)
}

application {
    // Define the main class for the application.
    mainClass.set("JavaFxApp")

    // Alternatively, you can run a Kotlin example, as follows:
    // mainClass.set("KotlinJavaFxApp")
}

tasks.withType<JavaExec> {
    // Assign all Java system properties from
    // the command line to the JavaExec task.
    systemProperties(System.getProperties().mapKeys { it.key as String })
}

Embedding Fuzio into JavaFX 

There are two JavaFX app implementations in the project: Java and Kotlin.

Both implementations are similar and demonstrate how to:

  1. Initialize an engine (Chromium) instance.
  2. Create a browser instance.
  3. Load the required web page.
  4. Embed a web view component into a JavaFX scene to display the loaded web page:
Java
Kotlin
// JavaFxApp.java:

import static tech.fuzio.engine.RenderingMode.HARDWARE_ACCELERATED;

import tech.fuzio.engine.Engine;
import tech.fuzio.view.javafx.BrowserView;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public final class JavaFxApp extends Application {

    @Override
    public void start(Stage primaryStage) {
        // Initialize Chromium.
        var engine = Engine.newInstance(HARDWARE_ACCELERATED);

        // Create a Browser instance and load the required web page.
        var browser = engine.newBrowser();
        browser.navigation().loadUrl("https://html5test.jiku.co");

        // Create and embed JavaFX BrowserView component to display web content.
        var view = BrowserView.newInstance(browser);
        
        var scene = new Scene(new BorderPane(view), 1280, 800);
        primaryStage.setTitle("Fuzio JavaFX");
        primaryStage.setScene(scene);
        primaryStage.show();

        // Shutdown Chromium and release allocated resources.
        primaryStage.setOnCloseRequest(event -> engine.close());
    }
}
// KotlinJavaFxApp.kt:

import tech.fuzio.dsl.Engine
import tech.fuzio.engine.RenderingMode.HARDWARE_ACCELERATED
import tech.fuzio.view.javafx.BrowserView
import javafx.application.Application
import javafx.scene.Scene
import javafx.scene.layout.BorderPane
import javafx.stage.Stage

class KotlinJavaFxApp : Application() {
    override fun start(primaryStage: Stage) {
        // Initialize Chromium.
        val engine = Engine(HARDWARE_ACCELERATED)

        // Create a Browser instance and load the required web page.
        val browser = engine.newBrowser()
        browser.navigation().loadUrl("https://html5test.jiku.co")

        // Create and embed JavaFX BrowserView component to display web content.
        val view = BrowserView.newInstance(browser)
        
        val scene = Scene(BorderPane(view), 1280.0, 800.0)
        primaryStage.title = "Fuzio JavaFX"
        primaryStage.scene = scene
        primaryStage.show()

        // Shutdown Chromium and release allocated resources.
        primaryStage.setOnCloseRequest { engine.close() }
    }

    fun run() {
        launch()
    }
}

fun main() {
    KotlinApp().run()
}

Run the JavaFX application 

Use the following command to build and run JavaFX application:

./gradlew run -Dfuzio.license.key=<your_license_key>

Once launched, you will see a JavaFX application with a BrowserView component displaying https://html5test.jiku.co:

BrowserView in JavaFX app

What’s next 

Customer Support

QR code to follow us on WeChat

Technical Support

QR code to follow us on WeChat