Reputation: 1187
In swing i have a component JEditorPane with JScrollPane i want to take print out of the content of jeditorpane. and i should have the flexibility to change the heading of printing page at runtime. I am using the following code but its not working
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)
{
}
Upvotes: 1
Views: 123
Reputation: 57381
You can use the editor kit independet printer http://java-sl.com/JEditorPanePrinter.html
To add page headers just modify root view's paint() method adding your content above.
Upvotes: 1