Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple printing an Image  RSS feed

 
Grzegorz Orczykowski
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!
I have got a problem with printing an Image in java. I found my code somewhere on the internet. The problem is that sometimes it prints all good but sometimes the blank page is printed. My printer works well and the path to the graphic is good. I do not change anything in the code and the results are different. Could someone tell me what is wrong?
 
Tony Docherty
Bartender
Posts: 3195
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the image file ever change? because getImage() caches images keyed on the filename so if an image changes you may get an old cached image.
Some image loading is done asynchronously (not sure about getImage) so it maybe that the image isn't fully loaded when you try to print it.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony is right. You'll need a MediaTracker to help you identify when the image has fully loaded. Alternatively, you can go the lazy way and use ImageIcon to load the image for you. This does the hard work for you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!