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

Cross-platform pageDialog and printDialog top margin entry broken

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      b117
    • CPU:
      x86
    • OS:
      windows_xp

      Backports

        Description

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

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

        A DESCRIPTION OF THE PROBLEM :
        The PrinterJob cross-platform page setup dialog top margin entry is broken. If you enter a value in the top margin field and hit "OK", the value is not updated in the PageFormat instance return value, nor is it updated in the attribute set used to call the pageDialog method. Tabbing out of the top margin field before hitting OK does not fix the problem. Likewise, clicking on a different margin entry field before hitting OK also does not fix the problem. However, if you change the top margin and then tab or click into a different margin entry field and change the value in that field, then the change to the top margin takes effect (along with the change to the other margin). The problem only affects the top margin whereas the left, right, and bottom margins work fine.

        The same top margin problem occurs in the "Page Setup" tab of the PrinterJob cross-platform print dialog. The problem can be illustrated by calling the cross-platform printDialog repeatedly, changing the margin values, and observing what happens to the top margin depending on whether other margin values are also changed.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile and run the test code provided. It calls the pageDialog 5 times in a row, then the printDialog 5 times in a row, providing multiple opportunities to edit margin values and see what happens. Change the top margin with and without changing other margin values, then hit "OK" and observe how the top margin entries are affected.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Should be able to enter top margin values, hit OK, and have them take effect.
        ACTUAL -
        Changes to top margin values are ignored unless another margin field is also changed before hitting OK.

        REPRODUCIBILITY :
        This bug can be reproduced always.

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

         public class Test {
             static public void main(String args[]) {
                 PrinterJob pj = PrinterJob.getPrinterJob();
                 try {
                     HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
                     PageFormat pf;
                     for (int i=0; i<5; i++) {
                         pf = pj.pageDialog(aset);
                         double left = pf.getImageableX();
                         double top = pf.getImageableY();
                         System.out.println("pageDialog - left/top from pageFormat: " + left / 72 +
                                            " " + top / 72);
                         System.out.println("pageDialog - left/top from attribute set: " +
                                            getPrintableXFromASet(aset) + " " +
                                            getPrintableYFromASet(aset));
                     }
                     for (int i=0; i<5; i++) {
                         boolean ok = pj.printDialog(aset);
                         System.out.println("printDialog - left/top from attribute set: " +
                                             getPrintableXFromASet(aset) + " " +
                                             getPrintableYFromASet(aset));
                     }
                 } catch (Exception e) { e.printStackTrace(); }
                 System.exit(0);
             }
             
            
             static double getPrintableXFromASet(PrintRequestAttributeSet aset) {
                 try { return ((MediaPrintableArea) aset.get(MediaPrintableArea.class)).getX(MediaPrintableArea.INCH);
                 } catch (Exception e) { return -1.0; }
             }
            
             static double getPrintableYFromASet(PrintRequestAttributeSet aset) {
                 try { return ((MediaPrintableArea) aset.get(MediaPrintableArea.class)).getY(MediaPrintableArea.INCH);
                 } catch (Exception e) { return -1.0; }
             }
         
        }


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

        CUSTOMER SUBMITTED WORKAROUND :
        No workaround found

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                psadhukhan Prasanta Sadhukhan
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: