Tool for HTML displaying
Answered
Hello.
I want to exclude javafx from my plugin due to its absence in jdk 11. The display of HTML content remains as a problem in my plugin. At the moment I use javafx.scene.web.WebView.
Java Swing lacks the analogues. JEditorPane works with CSS insufficiently well. I tried to find utility classes in openapi, but all I’ve found was SwingHelper.HtmlViewerBuilder, which also returns object JEditorPane.
Can you please advise me a tool in openapi, which resembles in its functionaly the javafx.scene.web.WebView. If not, are there any plans for creating such tool in the nearest future?
Thank you.
Please sign in to leave a comment.
JavaFX WebView supports JavaScript and it's HTML/CSS processing is what you would expect from a browser. On the other hand Swing browser implements a very limited version of HTML/CSS functionality, no JavaScript.
If you can live with the limitations then Swing browser will work just fine, otherwise you need JavaFX WebView.
The code in my OSS repo is a bit dated but the Swing browser implementation has not changed much: https://github.com/vsch/idea-multimarkdown/blob/master/src/main/java/com/vladsch/idea/multimarkdown/editor/MultiMarkdownPreviewEditor.java#L271-L285
You will need to look at the setStyleSheet() code for Swing browser CSS handling and https://github.com/vsch/idea-multimarkdown/blob/master/src/main/java/com/vladsch/idea/multimarkdown/editor/MultiMarkdownEditorKit.java which handles customizations.
Keep in mind Swing rendering is very limited and idiosyncratic. It will not look like anything you get from WebView.
And what about internal intellij openapi tools? Do you have plans for creating such tools in future?
From what I know the internal tools use Swing JEditorPanel. They do not require JavaScript or accurate browser like rendering.
You may require that JavaFX be installed for your plugin to work since JavaFX is available for jdk 11 and the bundled jdk 11 does have JavaFX.
Ok. Thank you.