简体   繁体   English

如何在框架中打开网页?

[英]How do I get a webpage to open up in a frame?

How do I get a webpage to open up in a frame? 如何在框架中打开网页?

(I'm using netbeans and java) (我正在使用netbeans和java)

eg 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? 我怎样才能做到这一点?

Here is a quick example of how to load google with the JEditorPane. 这是一个如何使用JEditorPane加载谷歌的快速示例。 I hope this is what you are looking for, but I'm still not 100% sure what exactly you want. 我希望这是你正在寻找的,但我仍然不能100%确定你想要什么。 If you could provide a bit more information about what you are doing I would be able to help you more. 如果您能提供更多有关您正在做的事情的信息,我将能够为您提供更多帮助。

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();
    }

}

Hope this helps 希望这有帮助

but if you just want something like FRAME in html, this will help you. 但如果您只想在html中使用FRAME之类的内容, 将对您有所帮助。

There is also a "Mozilla Widget for Java Swing" call MozSwing , but maybe it's not what you want :) 还有一个“用于Java Swing的Mozilla Widget”调用MozSwing ,但也许它不是你想要的:)

So you are asking for a webbrowser (.net) control equivalent in J2SE. 所以你要求在J2SE中使用webbrowser(.net)控件。 As far as I know there is no equivalent for it in J2SE. 据我所知,J2SE中没有相应的东西。

There only is JEditorPane which is very very weak. 只有JEdi​​torPane非常弱。

Edit: There are some commercial components: 编辑:有一些商业组件:

One of them is ICEbrowser 其中之一是ICEbrowser

The default JEditorPane is very poor. 默认的JEditorPane非常差。 It can only render HTML 3.2. 它只能呈现HTML 3.2。 With JWebEngine you can display HTML 4. JWebEngine is pure Java and platform independent. 使用JWebEngine,您可以显示HTML 4. JWebEngine是纯Java和平台无关的。 The ICEbrowser is EOL. ICEbrowser是EOL。

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

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