I have to browse Html files in java windows application software . For it i am using JEditorPane control but its not supporting some tags of HTML and formatting is disturbing in JEditorPane. I have searched on net and net is suggesting me to use JavaFXApplication control for it . In C# there is a control WebBrowser that displays the html file in the same format easily . Is it possible in java too to display the html files with all supporting tags .
Can you suggest me the control or something wrong in my code.I am using the following code.
try
{
File htmlfile= new File("path of the html file");
JEditorPane htmlPane= new JEditorPane();
htmlPane.setEditable(false);
htmlPane.setContentType("text/html");
htmlPane.setPage(htmlfile.toURI().toURL());
JScrollPane jsp= new JScrollPane(htmlPane);
add(jsp);
}
catch(Exception ex)
{
}
If I understand your question correctly, you are trying to view the HTML SOURCE and not trying to implement a web browser.
If that’s the case you can use JavaFX’s HTML editor assuming you are using Java 6 with JavaFX OR Java 7 which includes JavaFX
Here’s a short sample of using the javafx package using the JFXPanel and HTMLEditor: