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

PrinterJob cross-platform print dialog fails to pass top margin field data

XMLWordPrintable

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

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

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

      A DESCRIPTION OF THE PROBLEM :
      On the Page Setup tab of the cross-platform print dialog there is a field to enter the top margin. The data entered in this field is not passed to the PrintRequestAttributeSet after the dialog is closed. The other options, left, right and bottom, do modify the value in the AttributeSet.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a PrinterJob and HashPrintRequestAttributeSet. Open the cross-platform print dialog with PrinterJob.printDialog(PrintRequestAttributeSet). Attempt to modify the top margin on the Page Setup tab.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
        Top margin would be changed by an entry in the field.
      ACTUAL -
        Top margin cannot be changed by entering data in the top margin field.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class PrintTest implements Printable {
          private void render(Graphics g, PageFormat pf) {
              g.drawRect((int)pf.getImageableX(),(int)pf.getImageableY(),72,72);
              g.drawLine((int)pf.getImageableX(),(int)pf.getImageableY(),72,72);
              g.drawLine((int)pf.getImageableX() + 72,(int)pf.getImageableY(),
               (int)pf.getImageableX(),(int)pf.getImageableY() + 72);
          }

          public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
              int retcod = Printable.PAGE_EXISTS;
              if (pageIndex == 0) {
                  render(g,pageFormat);
              } else
                  retcod = Printable.NO_SUCH_PAGE;

              return retcod;
          }

          public static void main(String[] args) {
              PrintTest pt = new PrintTest();
              PrinterJob pj = PrinterJob.getPrinterJob();
              pj.setPrintable(pt);
              HashPrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
      // set.add(new MediaPrintableArea(25.4f,50.8f,165.1f,203.2f,
      // MediaPrintableArea.MM));
              if (pj.printDialog(set)) {
                  Attribute[] atts = set.toArray();
                  for (Attribute att : atts)
                      System.out.println(att);
                  /*
                  try {
                      pj.print(set);
                  } catch (PrinterException pe) {
                      pe.printStackTrace();
                  }
                  */
              }
          }
      }


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

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround.

            psadhukhan Prasanta Sadhukhan
            jgodinez Jennifer Godinez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: