Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6604111

inconsistent behavior of PrinterJob.pageDialog

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 9
    • 6
    • client-libs
    • 2d
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_02"
      Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      When pageDialog is called with PrintRequestAttributeSet, changing a margins textfield and pressing CRLF causes the change to be discarded and the dialog box closed. When pageDialog is called with PageFormat, the native dialog correctly handled the change before closing the dialog box.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) compile and run the folowing program
      2) click a margins field, make some changes
      3) press ENTER

      import java.awt.print.*;
      import javax.print.*;
      import javax.print.attribute.*;
      import javax.print.attribute.standard.*;
      import java.awt.*;
       
      public class pageDialog implements Printable {
         public static void main(String[] args) {
      PrintRequestAttributeSet aset=new HashPrintRequestAttributeSet();
      aset.add(new MediaPrintableArea(.5f,.5f,7.5f,10f,MediaPrintableArea.INCH));
      PrinterJob PJ=PrinterJob.getPrinterJob();
      PageFormat pageFormat=PJ.pageDialog(aset);
      System.out.println((pageFormat.getImageableX()/72f)+" "+
      (pageFormat.getImageableY()/72f)+" "+
      (pageFormat.getImageableWidth()/72f)+" "+
      (pageFormat.getImageableHeight()/72f)
      );
         }
         public int print(Graphics g, PageFormat pageFormat, int PI) throws PrinterException {
      return NO_SUCH_PAGE;
         }
      }



      -------------------------
      follow the same steps outlined above and you'll see that the native dialog correctly handle the change:

      import java.awt.print.*;
      import javax.print.*;
      import javax.print.attribute.*;
      import javax.print.attribute.standard.*;
      import java.awt.*;

      public class pageDialog implements Printable {
         public static void main(String[] args) {
      PrinterJob PJ=PrinterJob.getPrinterJob();
      PageFormat pageFormat=PJ.defaultPage();
      pageFormat.setOrientation(PageFormat.LANDSCAPE);
      Paper paper=new Paper();
      paper.setImageableArea(36f,36f,540f,720f);
      pageFormat.setPaper(paper);
      pageFormat=PJ.pageDialog(pageFormat);
      System.out.println((pageFormat.getImageableX()/72f)+" "+
      (pageFormat.getImageableY()/72f)+" "+
      (pageFormat.getImageableWidth()/72f)+" "+
      (pageFormat.getImageableHeight()/72f)
      );
         }
         public int print(Graphics g, PageFormat pageFormat, int PI) throws PrinterException {
      return NO_SUCH_PAGE;
         }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      after making the change and pressing ENTER, the change should be saved and the dialog box closed
      ACTUAL -
      after making the change and pressing ENTER, the change was discarded

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      call pageDialog with PageFormat

            psadhukhan Prasanta Sadhukhan
            prr Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: