2016-08-20 92 views
1

我在我的程序中将我的JEditorPane返回到了一个网站,例如google example, ,但它没有正确显示该页面,没有其CSS样式。 呃, 检查我的代码:在JEditorPane上正确显示网站java

JEditorPane editorPane = new JEditorPane() { 
     public boolean getScrollableTracksViewportWidth() { 
      return true; 
     }}; 

    editorPane.setEditable(false); 

    HTMLEditorKit kit = new HTMLEditorKit(); 
    Document doc = kit.createDefaultDocument(); 
    editorPane.setDocument(doc); 
    editorPane.setEditorKit(kit); 

    try { 
     editorPane.setContentType("text/html"); 
     editorPane.setPage("http://www.google.fr/"); 
    }catch (IOException e) { 
     editorPane.setContentType("text/html"); 
     editorPane.setText("<html>We can't load this page</html>" 
       + e.getMessage() + " "); 
    } 

    editorPane.setBounds(295, 265, 491, 474); 
    editorPane.setBorder(new LineBorder(new Color(0, 0, 0))); 

    pan.add(editorPane); 

我只是想表明一个Java组件网站来显示新闻和其他信息, 谁能帮助我吗?

回答