This is a URL handler I needed for my javafx application in order to allow WebView (WebEngine) find my classpath resources and use relative resources for images, scripts, etc. If you only use WebEngine.loadContent, you cannot use relative resources and your web pages become much less flexible when changing later.
/**
* Handler factory different types of URL handling.
*/
class ConfigurableStreamHandlerFactory extends URLStreamHandlerFactory {
private var handlers = Map[String, URLStreamHandler]()