2016-08-20 100 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組件網站來顯示新聞和其他信息, 誰能幫助我嗎?

回答