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!