java 如何让网页在框架中打开?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1988202/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I get a webpage to open up in a frame?
提问by Tuffy G
How do I get a webpage to open up in a frame?
如何让网页在框架中打开?
(I'm using netbeans and java)
(我正在使用 netbeans 和 java)
e.g in a html page you can use
例如在您可以使用的 html 页面中
<frame src="http://www.google.com">
and it will display google in the frame.
它将在框架中显示谷歌。
I don't want it to open a browser, just to open up within the frame. How can I do that?
我不希望它打开浏览器,只是在框架内打开。我怎样才能做到这一点?
回答by Anton
Here is a quick example of how to load google with the JEditorPane. I hope this is what you are looking for, but I'm still not 100% sure what exactly you want. If you could provide a bit more information about what you are doing I would be able to help you more.
这是如何使用 JEditorPane 加载 google 的快速示例。我希望这就是您要找的东西,但我仍然不能 100% 确定您到底想要什么。如果您能提供更多有关您在做什么的信息,我将能够为您提供更多帮助。
import javax.swing.*;
public class GetWebPage {
public static void main(String args[]) throws Exception {
JEditorPane website = new JEditorPane("http://www.google.com/");
website.setEditable(false);
JFrame frame = new JFrame("Google");
frame.add(new JScrollPane(website));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.pack();
}
}
回答by Michel Gokan
回答by JCasso
So you are asking for a webbrowser (.net) control equivalent in J2SE. As far as I know there is no equivalent for it in J2SE.
因此,您要求在 J2SE 中使用等效的 webbrowser (.net) 控件。据我所知,在 J2SE 中没有等效的东西。
There only is JEditorPanewhich is very very weak.
只有JEditorPane非常非常弱。
Edit: There are some commercial components:
编辑:有一些商业组件:
One of them is ICEbrowser
其中之一是ICEbrowser
回答by Horcrux7
The default JEditorPane is very poor. It can only render HTML 3.2. With JWebEngineyou can display HTML 4. JWebEngine is pure Java and platform independent. The ICEbrowser is EOL.
默认的 JEditorPane 很差。它只能呈现 HTML 3.2。使用JWebEngine,您可以显示 HTML 4。JWebEngine 是纯 Java 和平台无关的。ICEbrowser 已停产。

