我必须在 java windows 应用软件中浏览 Html 文件。为此,我正在使用 JEditorPane 控件,但它不支持 HTML 的某些标签,并且格式在 JEditorPane 中令人不安。我在网上搜索过,网上建议我使用 JavaFXApplication 控件。在 C# 中有一个控件 WebBrowser 可以轻松地以相同格式显示 html 文件。是否也可以在 java 中显示带有所有支持标签的 html 文件。你能给我建议我的代码中的控件或错误吗?我正在使用以下代码。
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)
{
}