• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OutOfMemoryError during Print Preview

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic