Search code examples
javajavafxjxbrowser

JXBrowser - How to import BrowserView component into SceneBuilder


I am writing a JavaFX application using JXBrowser. I seem to be having some trouble however figuring out how to add the BrowserView component into Scene Builder.

I have tried importing all of the .jar's into Scene Builder and attempted to create a custom component for it but to no avail.

I have exhausted all of my google fu.

Tested on Scene Builder 8 and 10. Tested Java Sources 8 through 10.


Solution

  • JxBrowser supports BrowserView import only via the code or FXML file. Import via the SceneBuilder is not supported as specific requirements should be met in order to import BrowserView using SceneBuilder.

    Import via the code is performed in the following way. Please check the example below.

    @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");
        }
    

    Import via the FXML file is described in this article, please take a look at the FXML section: https://jxbrowser.support.teamdev.com/support/solutions/articles/9000013071-using-jxbrowser-in-javafx