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: 4267324
Votes 0
Synopsis two subsequent prints fail if printDialog is invoked in-between
Category java:classes_2d
Reported Against kestrel-beta
Release Fixed
State 11-Closed, Not Reproducible, bug
Priority: 4-Low
Related Bugs
Submit Date 31-AUG-1999
Description




Bug on Solaris.
1. The code below prints the second page backwards, upside down an in a larger font.
    This bug has been fixed in Kestrel for win32. On win32 the second page would come out blank, but the problem still exists in Kestrel.

2. Source code follows

/////////////print bug test///////////////////
import java.awt.*;
import java.awt.print.*;

class Main implements Printable {
public static void main(String[] args) {
PrinterJob pj = PrinterJob.getPrinterJob();

pj.setCopies(1);
pj.setPrintable(new Main());

//first try
pj.printDialog();
try {
pj.print();
} catch(Exception e) {}

//second try
pj.printDialog();
try {
pj.print();
} catch(Exception e) {}
}

public int print(Graphics g, PageFormat pf, int pageIndex) 
throws PrinterException {
if (pageIndex > 0) { 
	return Printable.NO_SUCH_PAGE; 
}
g.setColor(Color.black);
g.drawString("Test", 100, 100);

return Printable.PAGE_EXISTS;
}
}
////////////end of source code///////////////

3. No error message

4. No trace info

5. 
> jv
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-D)
Java(TM) HotSpot Client VM (build 1.3beta-D-release, 1.3beta-D-release, interpreted mode)

6. Use printers hooked up to the network
(Review ID: 94661) 
======================================================================
Work Around




To work around recreate the PrinterJob in-between the two prints.

pj = PrinterJob.getPrinterJob();
======================================================================
Evaluation
leaving aside the printDialog invocation, it appears that the test case
is invoking print() twice on the same PrinterJob.
Its not clear if the API intended this to be permitted.
We need to either throw a PrinterException on 2nd and subsequent calls to
print, or we need to support this and make it work ..
will consider this post-kestrel, since its not a very common need and the
workaround is probably the way most people write code anyway ..

 xxxxx@xxxxx  1999-09-23
=========================

I've tried this with the 1.3 solaris FCS release and the 1.4 beta and this
bug is not reproducible.
The API does not make a statement as to whether this is valid although it
probably ought to. Intuitively it would seem that a "job" is a single use
object.
Also there is no benefit to re-using a PrinterJob in this way.
It is recommended to create a new PrinterJob object (a cheap
operation, particularly compared to the cost of executing the print() method).
Closing as not reproducible but could easily have been will not fix.

 xxxxx@xxxxx  2001-05-14
========================
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang