I use PrinterJob.printDialog()
to let the user select a printer and change various print settings.
However the dialog is always displayed using the standard Java coffeecup icon and not the one from my main window (JFrame).
How can I change the icon for that dialog?
I'm using the following piece of code:
PrinterJob pj = PrinterJob.getPrinterJob(); pj.printDialog(); // how do I change the icon for the dialog that is displayed here ... // process the selection from the dialog
Normally a JDialog inherits the icon from the "parent" JFrame, but in this case I cannot pass or specify a parent window for that dialog
I'm using Java6
I have not found a way to change the icon, but here is one indirect way to Remove it.
You need to specify a DialogOwner via the print attributes. This causes java.awt.Window to not use the default Java icon.
PrinterJob pj = PrinterJob.getPrinterJob();
// Create an Attribute set
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
// A different way to bring Up Native Dialog from Java
aset.add(sun.print.DialogTypeSelection.NATIVE);
// Looks like this class is being moved to javax.print.attribute.standard for Java 7
// To Remove the Icon from the dialog provide an owner.
Frame f = Frame();
aset.add(new sun.print.DialogOwner(f));
pj.printDialog(aset); // The dialog should not have an icon now.
Hope this helps you for now!!
While I continue to search for some way to position this print dialog. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With