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: 4198400
Votes 0
Synopsis getCopies does not work on win32
Category java:classes_2d
Reported Against 1.2fcs
Release Fixed
State 11-Closed, duplicate of 4168555, bug
Priority: 4-Low
Related Bugs 4168555
Submit Date 17-DEC-1998
Description




The method "getCopies()" does not return the number of copies
in case the user changed it in the printDialog(). When you
do a setCopies() the number of copies will be shown in the
printDialog(), but when you change it and call getCopies() you
will always get the number back you sent in using "setCopies()".

Example: 
import java.awt.*;
import java.awt.print.*;
import java.awt.print.PageFormat;
import java.awt.geom.*;
import java.lang.*;
	
public class PrintTest {
	

  public static void main(String[] args) {

  	PrinterJob job = PrinterJob.getPrinterJob();
		job.setCopies(1);	// this works fine, 2 is displayed in the printer dialog
  	PageFormat pfDefault;
  	if (job.printDialog()) {
  		pfDefault=job.pageDialog(job.defaultPage());
  		int cnCopies=job.getCopies();		// this will always return 2 although changed in the dialog
		  Book bk = new Book();
   		bk.append(new CClippedRect(),pfDefault);
  		job.setPageable(bk);
 			try { 
				job.print(); 
      }   
 			catch (Exception exc) { 
				System.out.println("Printer Exception");
 			}		
  	}				
 	}
}

class CClippedRect implements Printable {
  public int print(Graphics g, PageFormat pf, int pageIndex)
        throws PrinterException {

    Graphics2D g2=(Graphics2D)g;
		BasicStroke stroke=new BasicStroke(0.2f);
		g2.setStroke(stroke);
    g2.setColor(Color.black);
    Rectangle r=new Rectangle();
    g2.getClipBounds(r);   
    //g2.drawRect(r.x+5,r.y+5,r.width-10,r.height-10);	// bottom line will not be printed at all
		r.x+=10;
    r.y+=10;
    r.width-=20;
    r.height-=20;
    g2.drawLine(r.x,r.y,r.x+r.width,r.y);
  	g2.drawLine(r.x,r.y,r.x,r.height);
   	g2.drawLine(r.x+r.width,r.y,r.x+r.width,r.height);
   	g2.drawLine(r.x+r.width,r.height,r.x,r.height);

    // Remove next comment in oder to see bug 
    // g2.drawRect(r.x,r.y,r.width,r.height-5);	// bottom line will be printed much too fat
		return(PAGE_EXISTS);
 }
}
(Review ID: 48107)
======================================================================
Work Around




nope!
======================================================================
Evaluation
Reassigning to 2D.
  xxxxx@xxxxx   1999-07-27
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang