2012-10-26 16 views
1

在swing中我有一個組件JEditorPane與JScrollPane我想打印出jeditorpane的內容。我應該可以靈活地在運行時更改打印頁面的標題。我使用下面的代碼,但它不工作jeditor窗格的打印

try{ 
    JEditorPane editorpane1= new JEditorPane(); 
    editorpane1.setContentType("text/html"); 
    editorpane1.setEditable(false); 
    File file1= new File("path of the html file"); 
    URL url= new URL(file1); 
    editorpane1.setPage(url); 
    JScrollPane jsp= new JScrollPane(editorpane1); 
    editorpane1.print(); 
    } 
catch(Exception ex) 
{ 

    } 
+0

打印到文件或打印機 – mKorbel

回答