需要在窗体里嵌入网页,有这样的控件吗?小弟实在没分,多包涵,先谢过!

解决方案 »

  1.   

    请教2楼大哥
    那在html里的超链接和其它的按钮等功能是不是也能实现啊?
      

  2.   

    可以的,JEditorPane只支持html和rtf,可以用来浏览简单的html文档
      

  3.   

    不行啊,超链接能显示出来,可是按钮不能显示。只显示‘>’个。
    窗体源代码:
    package Frame;import java.awt.Color;
    import java.io.IOException;
    import java.net.URL;
    import java.net.URLClassLoader;
    import javax.swing.*;public class FrameOne extends JFrame {
    public FrameOne() throws IOException{
    JEditorPane EditorPane= new JEditorPane();
    URL url = this.getClass().getResource("/Frame/help.html");
    EditorPane.setEditable(false);
    EditorPane.setPage(url); 
    this.add(EditorPane);
    }
    }
    HTML源代码:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Index page!!!!</title>
    </head>
    <body>
    <table width="200" border="1" align="center">
      <tr>
        <td align="center"><input type="button" value="请点击"/></td>
      </tr>
      <tr>
        <td align="center"><input type="button" value="请点击"/></td>
      </tr>
      <tr>
        <td align="center"><input type="button" value="请点击"/></td>
      </tr>
    </table>
    <p><a href="test.html">111111111111</a></p>
    </body>
    </html>主函数源代码:
    package Main;import java.io.IOException;
    import Frame.FrameOne;public class MainTest {
    public static void main(String[] args) throws IOException {
    FrameOne fo = new FrameOne();
    fo.setSize(new Dimension(800,600));
    fo.setVisible(true);
    }
    }结果:
      

  4.   

    没错,JEditorPane可以。
    也可以用JNI内嵌一个IE浏览器,不过这会破坏Java程序移植性,除非只在Windows上运行。