Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4694495
Votes 0
Synopsis Native printDialog() doesn't display setCopies() after setPrintService()
Category java:classes_2d
Reported Against 1.4
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 30-MAY-2002
Description




FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


FULL OPERATING SYSTEM VERSION :
Windows 98 [Version 4.10.2222]


A DESCRIPTION OF THE PROBLEM :
Under JDK 1.4 if you use setPrintService(PrintService) to
select a printer programmatically, then use the native
setCopies(int) to specify a number of copies, and then use
the native print() to print, the specified number of copies
will be printed on the selected printer.

But if you call the native printDialog() after
setCopies(int), the number of copies shown in the dialog is
always 1 and saying OK results in only 1 copy printed.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Build and run program below
2. Note number of copies in print dialog that appears.


EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
Print dialog says "Number of copies: 3"

Actual:
Print dialog says "Number of copies: 1"


ERROR MESSAGES/STACK TRACES THAT OCCUR :
None


This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;

public class Test {
	static public void main(String args[]) {
		DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
		PrintRequestAttributeSet aSet
                    = new HashPrintRequestAttributeSet();
		PrintService[] services
                    = PrintServiceLookup.lookupPrintServices(flavor, aSet);
		PrinterJob pj = PrinterJob.getPrinterJob();
		for (int i=0; i<services.length; i++)
                    System.out.println(services[i].getName());
        	try { pj.setPrintService(services[services.length-1]); }
		catch (Exception e) { e.printStackTrace(); }
		pj.setCopies(3);
		pj.printDialog();
		System.exit(0);
	}
}


---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Use the JDK 1.4 cross-platform print dialog and the "Copies"
PrintRequestAttribute.
(Review ID: 145945) 
======================================================================
Work Around
N/A
Evaluation
---------
'nCopies' of PRINTDLG was set to 3 but not DEVMODE's dmCopies.  We need to also set dmCopies if devmode is not null.

 xxxxx@xxxxx  2002-07-31
--------

Fixed as described above.

 xxxxx@xxxxx  2002-09-18
----------------------------------
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang