想做JAVA做一个简单的浏览器,试过用JEditorPane,效果不理想(如显示百度的首页都很难看)现在想用JAVA做一个IE内核的浏览器,能实现吗?

解决方案 »

  1.   

    当然能了,也就是解析HTML,然后解释JS,VBS什么的,然后画图显示个网页的元素什么的。
    本质上不是很难,但是写的完美了就困难了。
      

  2.   

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.browser.Browser;
    import org.eclipse.swt.browser.ProgressEvent;
    import org.eclipse.swt.browser.ProgressListener;
    import org.eclipse.swt.browser.TitleEvent;
    import org.eclipse.swt.browser.TitleListener;
    import org.eclipse.swt.layout.FillLayout;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;public class Snippet159 {
      public static void main(String[] args) {
        final String newTitle = "New Value for Title";
        Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        final Browser browser = new Browser(shell, SWT.NONE);
        browser.addTitleListener(new TitleListener() {
          public void changed(TitleEvent event) {
            System.out.println("TitleEvent: " + event.title);
            shell.setText(event.title);
          }
        });
        browser.addProgressListener(new ProgressListener() {
          public void changed(ProgressEvent event) {
          }      public void completed(ProgressEvent event) {
            /*
             * Set HTML title tag using JavaScript and DOM when page has
             * been loaded
             */
            boolean result = browser.execute("document.title='" + newTitle
                + "'");
            if (!result) {
              /*
               * Script may fail or may not be supported on certain
               * platforms.
               */
              System.out.println("Script was not executed.");
            }
          }
        });
        /* Load an HTML document */
        browser.setUrl("http://www.eclipse.org");
        shell.open();
        while (!shell.isDisposed()) {
          if (!display.readAndDispatch())
            display.sleep();
        }
        display.dispose();
      }
    }
      

  3.   

    可以看看firefox 的 ie tab 插件
      

  4.   

    如何在Java中嵌入IE
    http://blog.csdn.net/bovy/archive/2007/04/09/1557332.aspx
      

  5.   

    在我看来如果只是简单功能的话就用jeditorpane就可以了,没必要花那么大工夫