• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

printing from an applet toolbar the image displayed in the applet via a thread

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I have a JApplet which displays a tiff image. The applet uses JAI API and Java 2D for printing. I can zoom in . zoom out , invert the image and I am printing the displayed image also .
In the action handler class for the print button , I have made an inner class implementing printable and executing the print function.
I am doing printing via a separate thread as i don't want my action handler class to keep waiting till the image gets printed . The user should be able to manipulate the image after it has clicked on the "ok" of the print dialog, while the image is being printed. This is the reason for printing the image in a separate thread
and the actual printing process is a synchronized method called by the run method of the thread .
If I click on print button twice , one after another , the second image gets printed only after I get a response from the printer that image has been printed as expected (as the print method is synchronized ).
In the action handler class of print , I do not call join on the thread as I do not want it to wait for printing to get over ( printing of a tiff image actually takes a long time ?? )
Is there anyway to make the threads independent of the main applet . Like after firing the print command , if I close the applet and I haven't got a confirmation from the printer, I get a blank page or nothing but i get a response message from printer that printing is done .
Is it essential for a thread to wait till the printer sends a response that printing is over ?
Similarly , If after firing the printing command and without waiting for the confirmation from the printer , I refresh the applet , proper printing does not occur but I get a message from the printer that printing is done .
If i use synchronized method for printing and wait till the printer response from the printer comes without closing or refreshing the applet , printing occurs fine .
Can anyone please tell me what is actually happening and is there a better way to print and that printing occurs after the print command has been fired irrespective of the applet ?
Regards , Navneet
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"KangN",
your name is not valid as per the Javaranch name conventions. Please refer to the document located here
 
Paper jam tastes about as you would expect. Try some on this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic