简体   繁体   English

如何用Java的jsoup文档在框架中显示网页?

[英]How to display a web page in a frame from a jsoup document in Java?

I have to make a Web Browser, displaying the web pages from a DOM tree. 我必须创建一个Web浏览器,以显示DOM树中的网页。 I have the DOM tree done using jsoup library, but I don't know how to display the web page on a JEditorPane. 我已经使用jsoup库完成了DOM树,但是我不知道如何在JEditorPane上显示网页。

I have this: 我有这个:

Document domTree = BackEnd.getInstance().getDOM(linkBar.getText(), "GET", null);

which makes a Document (domTree), as a HTML document, that has the DOM tree of the web site entered in the link bar. 这将使文档(domTree)作为HTML文档,该文档在链接栏中输入了网站的DOM树。 How can I use this document to display the web page on that JEditorPane? 如何使用此文档在该JEditorPane上显示网页? Or do I have to use a different thing than JEditorPane? 还是我必须使用与JEditorPane不同的东西?

Usually JEditorPane is used to render HTML in Java swing. 通常,JEditorPane用于在Java swing中呈现HTML。 You just need to set the content type. 您只需要设置内容类型。 Since you have the document object ready try 由于您已经准备好文档对象,请尝试

editor.setContentType( "text/html" );    
editor.setText( domTree.html() );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM