hi,
I've noticed a minor bug when printing, if you move the print dialog box around the background doesn't repaint. If anyone else has this problem, I post a quick fix here where I do the printing on a separate thread.
minor changes to JFreeChartPanel-
Modify this method to read:
/**
* Creates a print job for the chart.
*/
public void createChartPrintJob() {
PrintThread thread = new PrintThread(this);
thread.start();
}
Add this class:
/**
* Class that does the printing on a separate thread.
*/
protected class PrintThread extends Thread {
private JFreeChartPanel chartPanel;
public PrintThread(JFreeChartPanel cp) {
super();
chartPanel = cp;
}
public void run() {
PrinterJob pj = PrinterJob.getPrinterJob();
if (pj.printDialog()) {
pj.setPrintable(chartPanel);
try {
pj.print();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
fix for minor print dialog bug
Re: fix for minor print dialog bug
Hi Matt,
Thanks for the fix. I'll incorporate it into the next version.
Regards,
DG
Thanks for the fix. I'll incorporate it into the next version.
Regards,
DG