I am using a JasperViewer to display the report inside of a Java desktop application.
The report consists of 2 pages – each of them represents an image.
The problem is, when user scrolls the page inside the viewer, there are huge freezes.
The size of image isn’t so big, about 1000×1000.
The image is generated in this way:
private BufferedImage createImage(Component panel) {
int w = (int) panel.getSize().getWidth();
int h = (int) panel.getSize().getHeight();
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
panel.paint(g);
g.dispose();
return bi;
}
The issue is resolved. There is a parameter in the JRViewer:
So, if this parameter is set, the reports is drawn as an
ImageIconon aJLabel. Otherwise, it’s drawn usingJRGraphics2DExporterthat is much more slower when working with big images.So the solution is to set the specified property in the property file or using way like this: