JxBrowser supports JavaFX toolkit and can be embedded into JavaFX desktop applications as well. To embed control that displays HTML content you must create com.teamdev.jxbrowser.chromium.javafx.BrowserView instance and put it into a Pane or any other container on Scene


Note: To use JxBrowser in JavaFX applications, JDK 1.8 or higher is required. 


The following sample demonstrates how to use JxBrowser in a simple JavaFX application:

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserCore;
import com.teamdev.jxbrowser.chromium.internal.Environment;
import com.teamdev.jxbrowser.chromium.javafx.BrowserView;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

/**
 * Demonstrates how to embed Browser instance into JavaFX application.
 */
public class JavaFXSample extends Application {

    @Override
    public void init() throws Exception {
        // On Mac OS X Chromium engine must be initialized in non-UI thread.
        if (Environment.isMac()) {
            BrowserCore.initialize();
        }
    }

    @Override
    public void start(final Stage primaryStage) {
        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);

        Scene scene = new Scene(new BorderPane(view), 700, 500);
        primaryStage.setScene(scene);
        primaryStage.show();

        browser.loadURL("http://www.google.com");
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Note: in macOS environment you must initialize JxBrowser core functionality in non-UI thread. For example, in the Application.init() method as shown below:

@Override
public void init() throws Exception {
    // On Mac OS X Chromium engine must be initialized in non-UI thread.
    if (Environment.isMac()) {
        BrowserCore.initialize();
    }
}