• Post Reply Bookmark Topic Watch Topic
  • New Topic

OutOfMemoryError during Print Preview  RSS feed

 
Ammata Soutdarany
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
U Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ammata Soutdarany
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by U Patel:


What is your heap size? increase it


It's 100 meg max. I'd like to figure out a solution without having to increase the heap size.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!