Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2005

Tip: Looking for answers? Try searching our database.

Custom Print Dialog

Thread view: 
dolly.tl@gmail.com - 14 Dec 2005 05:40 GMT
Is there any way to provide a custom print dialog rather than rely upon
the cross-platform dialogs provided? I have a need to change text and
add some customizations and have a GUI that i would like to show when
print is invoked.

Is there an example or suggestions as to how to override the PrinterJob
to return my customized print dialog? Also, if I do this, can I
populate the paper sizes, pageSetup and media attributes?

Really appreciate a reply.
Andrew Thompson - 16 Dec 2005 09:20 GMT
> Is there any way to provide a custom print dialog rather than rely upon
> the cross-platform dialogs provided? I have a need to change text and
[quoted text clipped - 3 lines]
> Is there an example or suggestions as to how to override the PrinterJob
> to return my customized print dialog?

Imagine your custom print dialog (popped from an invisible applet)
had two buttons, one which said 'OK' and printed 1 copy of the text,
the other which said Cancel and instead printed *100* copies of the
text (which is all 'important' promotional material - ads).

Can you see now, why you are unlikely to be able to change the
default print dialog with a custom one?

Signature

Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew

Thomas Weidenfeller - 16 Dec 2005 10:07 GMT
>> Is there any way to provide a custom print dialog rather than rely upon
>> the cross-platform dialogs provided?[...]
[quoted text clipped - 6 lines]
> the other which said Cancel and instead printed *100* copies of the
> text (which is all 'important' promotional material - ads).

A couple of things here:

- printing does not have to go through a displayed dialog at all. You
can print without ever asking the user anything

- Not the dialog, but the print job is protected by the security
manager. You can indeed fake a print dialog with a cancel button which
uses PrintJob.setCopies(1000) - if you are allowed to get a PrintJob

The conclusion from these two facts is, that you can simply design an
own print dialog from scratch, and present it to the user whenever you
like. You collect the data from the dialog, configure a PrintJob,
without using ant PrintJob dialogs accordingly and off you go.

If you want to play it more complex, the concrete PrintJob class used
(PrintJob itself is abstract), is specified via the java.awt.printerjob
system property. i haven't tried it, but it should be possible to
implement a subclass of PrintJob from scratch, and use that one to
replace the default implementation. This will get you whatever dialog
you want. But there is really not much to gain doing it this way,
because you can anyhow pop up your own dialog whenever you want.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Andrew Thompson - 16 Dec 2005 11:28 GMT
> A couple of things here:
[snip..]

..but then again, I may have been completely wrong
about that stuff.  ;-)

Signature

Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.