Quarkus FX

This extension allows you to use Java FX to your Quarkus application.


In order to use this extension, you need to add the io.quarkiverse.fx:quarkus-fx dependency to your project.




dependencies {
    implementation 'io.quarkiverse.fx:quarkus-fx:0.4.1'


The extension allows using cdi features in JavaFX controller classes.
The FXMLLoader is made a CDI bean and can be injected in your application.

FXMLLoader fxmlLoader;

public void load() {
  Parent root = this.fxmlLoader.load(this.getClass().getResourceAsStream("/app.fxml"));
  Scene scene = new Scene(root);
public class MyFxmlController {

  MyService myService;

  private void onButtonClicked() {


The application will automatically be launched (thanks to a call to javafx.application.Application::launch) when the extension is present.

If you need to customize the launch, you can provide a custom @QuarkusMain, such as :

package io.quarkiverse.fx.fxapp;

import io.quarkiverse.fx.FxApplication;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
import javafx.application.Application;

public class QuarkusFxApplication implements QuarkusApplication {
    public int run(final String... args) {
        Application.launch(FxApplication.class, args);
        return 0;

When the application is started, you can get obtain access to the primary Stage instance by observing the FxStartupEvent CDI event :

void onStart(@Observes final FxStartupEvent event) {
  Stage stage = event.getPrimaryStage();