在秋千上,我有一个带有JSCrollpane的组件Jeditorpane,我想从Jeditorpane的内容中打印出来。而且我应该有灵活性在运行时更改打印页面的标题。我正在使用以下代码,但它不起作用
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)
{
}
您可以使用编辑套件套件Indeptit打印机http://java-sl.com/jeditorpaneprinter.html
添加页面标头只是修改root view's Paint()方法,在上面添加您的内容。