0

I would like to create a window using JavaFX Web View to display a website in my Kotlin desktop application (not Android). Ideally, I would like to initiate an object that will pop up the website as a JavaFX window. Imagine that I want to display the terms and conditions of the software that are hosted on my website, I could create an object of MyWebView("https://example.com/terms") (my class below) and that should display a web view with that website.

Please note, I would like to avoid using TornadoFX.

Here is the code I tried but did not work:

import javafx.application.Platform
import javafx.scene.Group
import javafx.scene.Scene
import javafx.scene.input.KeyCode
import javafx.scene.input.KeyEvent
import javafx.scene.layout.VBox
import javafx.scene.web.WebView
import javafx.stage.Stage

class MyWebView : javafx.application.Application() {
    override fun start(stage: Stage) {
        stage.title = "HTML"
        val scene = Scene(Group())

        val root = VBox()

        val browser = WebView()
        browser.setPrefSize(2520.0, 1440.0)
        browser.engine.isJavaScriptEnabled = true
        browser.engine.load("https://google.com")
        root.children.addAll(browser)
        scene.root = root
        scene.addEventFilter(KeyEvent.KEY_PRESSED) {
            if (it.code == KeyCode.ESCAPE) {
                Platform.exit()
                System.exit(0)
            }
        }
        stage.scene = scene
        stage.isFullScreen = true
        stage.show()
    }
}

But I get:

Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found

Thank you!

Phrixus
  • 1,209
  • 2
  • 19
  • 36
  • I want to start by saying I do not know anything about `Kotlin`, so this info may not be correct. I looked [here](https://www.reddit.com/r/Kotlin/comments/aocgz1/kotlin_java11_javafx_pain_in_the_neck/) and people are saying `Kotlin` will not work with `JavaFX 9+`. I also found [this](https://thickclient.blog/2019/04/04/application-number-1/). Maybe it can help. I did not try it. – SedJ601 Apr 22 '22 at 17:49
  • My advice: first try to do this without kotlin and without webview. Just display a stage with a button. See if you can at least get that to work. If that works, then add webview display to your Java app. If that works, then add Kotlin. To do this, use the [new javafx project in Idea](https://www.jetbrains.com/help/idea/javafx.html). The wizard has options for both kotlin and java based apps, so will do the setup for you. Choose maven if you don't know gradle. Use latest stable software (especially if you have an M1 mac). – jewelsea Apr 22 '22 at 18:42
  • Instructions to [add webview support to an existing app](https://stackoverflow.com/a/70946444/1155209). – jewelsea Apr 22 '22 at 18:43
  • [97 questions asking about "Error initializing QuantumRenderer" here](https://stackoverflow.com/search?tab=votes&q=Error%20initializing%20QuantumRenderer). – jewelsea Apr 22 '22 at 19:27

0 Answers0