|
Quick Lists
|
|
Bug ID:
|
4168555
|
|
Votes
|
4
|
|
Synopsis
|
win32: only user can set a printjob's number of Copies
|
|
Category
|
java:classes_2d
|
|
Reported Against
|
1.2
, 1.1.6
, 1.2fcs
|
|
Release Fixed
|
1.3(kestrel)
|
|
State
|
10-Fix Delivered,
Needs Verification,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
4198400
|
|
Submit Date
|
24-AUG-1998
|
|
Description
|
In 1.2FCS on win32 if you specify the number of copies programatically
it appears in the printDialog.
But for the value to be used (including any new value set by the user), the
dialog must be exited with OK, not Cancel.
If you don't display the dialog, the value is not used either.
Finally, any value set by the user is not retrievable by getCopies()
The upshot of this is that only the user can specify more than one copy
and the application can't tell.
All of this is fixed for JDK 1.3 (kestrel)printDialog does not reflect a printjob's setCopies. Specifying 2 copies and the print dialog shows the value of 1. Compile & run attached src :
import java.awt.print.PrinterJob;
public class PrintTest {
public static void main(String s[]) {
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setCopies(2);
pj.printDialog();
System.exit(0);
}
}
java full version "JDK-1.2fcs-G"
xxxxx@xxxxx 1999-01-21
NOTE: Here's another test case that isn't a degenerate condition (from a user) and the same problem is shown. Furthermore, this code demonstrates that multiple copies don't even print (JDK 1.2 final on windows) and that the value returned by getCopies is bogus even if the user changed the value and okayed the dialog. It's more than just getCopies being wrong too, because the print method is only called as often as the setCopies() call specifies if it is called BEFORE the printDialog() method.
/*
** Platform: Chinese Win95 4.00.950 B
** Example:
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import javax.swing.*;
public class Big5PrintTest extends JPanel implements ActionListener
{
public Big5PrintTest()
{
setBackground(Color.white);
JButton b = new MyButton();
b.addActionListener(this);
add(b);
}
public void actionPerformed(ActionEvent e)
{
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable((MyButton) e.getSource());
System.out.println( "nCopies (1) = " + printJob.getCopies() ) ; // nCopies (1) = 1
printJob.setCopies(2) ;
System.out.println( "nCopies (2) = " + printJob.getCopies() ) ; // nCopies (2) = 2
if ( printJob.printDialog() ) // change 'copies' in the dialog
{
System.out.println( "nCopies (3) = " + printJob.getCopies() ) ;
// BUG: Any change of 'copies' in the dialog will not become effective.
//
// If setCopies(2) is called, nCopies (3) will be always equal to 2;
// if setCopies(2) is not called, nCopies (3) is always equal to 1,
// no matter what value is put to 'copies' in the dialog.
try { printJob.print(); }
catch (Exception PrintException) {}
}
}
public static void main( String[] args )
{
WindowListener l = new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
System.exit(0) ;
}
} ;
JFrame f = new JFrame( "Big5PrintTest" ) ;
f.addWindowListener(l);
JOptionPane.setRootFrame( f ) ;
f.getContentPane().add( new Big5PrintTest(), BorderLayout.CENTER ) ;
f.setSize(new Dimension(300,100));
f.show();
}
static class MyButton extends JButton implements Printable
{
public MyButton()
{
super( "Print" ) ;
}
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
{
if ( pi >= 1 )
{
return Printable.NO_SUCH_PAGE;
}
Graphics2D g2 = (Graphics2D) g;
g2.drawString( "Print Test", 100, 100 ) ;
return Printable.PAGE_EXISTS;
}
}
}
|
|
Work Around
|
N/A
|
|
Evaluation
|
The GDI PrintJob needed to have the number of copies to print set...
xxxxx@xxxxx 1998-08-31
still not fixed for Solaris. On winNT a Printing Error dialog appears : "An error occured during this operation."
java full version "Java2D:09-Sep- xxxxx@xxxxx :46"
xxxxx@xxxxx 1998-09-09
Now fixed for Solaris too...
xxxxx@xxxxx 1998-09-22
Looks okay on Solaris with L. But, on win32 a error dialog appears.
xxxxx@xxxxx 1998-09-30
Richard tested this on three NT drivers and didn't encounter the error. After looking at the code, he sees a possible problem that with some drivers might cause this behavior.
Still, it's a degenerate case since the sample code never sets a printable or pagable into the print job, so the print job has zero pages in it.
Something to do in 1.2+...
================
Here's what I see as the remaining problem :-
In 1.2FCS on win32 if you specify the number of copies programatically
it appears in the printDialog.
But for the value to be used (including any new value set by the user), the
dialog must be exited with OK, not Cancel.
If you don't display the dialog, the value is not used either.
Finally, any value set by the user is not retrievable by getCopies()
The upshot of this is that only the user can specify more than one copy
and the application can't tell.
===============================
|
|
Comments
|
Submitted On 25-JAN-1999
kurzw
Windows 98 - JDK 1.2
No modifications done in the page specification
dialog are returned to the requester.
Always the same imageable are is returned
and alwys the same starting point (72/72) is given back.
Submitted On 11-NOV-2003
TimoMatt
Hi.
Im having this problem on JDK 1.3.1. After the the user has
changed the number of copies in the print dialog, I want to
set the number of copies to 1 via setCopies(1). getCopies()
tells me that the number of copies is 1, but this is ignored
and the number of copies specified in the print dialog is
printed. Can anyone help me here?
Yours sincerely
Timo Maerte
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |