Display HTML String in a Browser


I am working on a project and have embedded a JavaFx Browser in a java application. Now, I would like to display some contents in the Browser.

I wanted to know that is there a way to display the contents through a string that contains HTML tags. I do not want to create a HTML file and the display the contents.

I was looking for something like JTextPane.

6/28/2012 1:20:18 PM

Accepted Answer

I could not investigate that JavaFX Browser Netbeans Module in depth. But if it is using a JavaFX WebView control internally then you can load String value containing HTML page (or tag) via WebView's WebEngine. See the WebEngine API for different content loadings. That Netbeans Module should have some interface API allowing this.

The method you want is webView.getEngine().loadContent(htmlString)

6/28/2012 4:11:31 PM

You have to change the < to &lt, followed by a semicolon, and change the > to &gt, followed by a semicolon.

Just like I did to type this answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow