Originally posted by Ammata Soutdarany:
I implemented a print preview and print function for a JTable. It works fine except for the case when the JTable contains too many rows. I get an OutOfMemoryError exception. Here's the way my print preview works.
Create a BufferedImage object the size of the table. (this is where it's throwing the exception)
Create a Graphics object from the BufferedImage.
Invoke JTable.printAll passing in the Graphics object.
The BufferedImage is now an image of the table.
When I call print, I paint a subimage of the BufferedImage onto the graphics object.
The only solution I can think of is to create a smaller BufferedImage and let the table paint a portion of itself onto the graphic object created by the BufferedImage. Is that possible to do?
Thanks,
Ammata
What is your heap size? increase it