JDK-6801613 : Cross-platform pageDialog and printDialog top margin entry broken
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u11,8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2009-02-05
  • Updated: 2021-10-07
  • Resolved: 2016-04-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u301Fixed 9 b117Fixed openjdk8u322Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
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

Comments
Fix Request (8u) A clean backport for parity with 8u321 and new test passed.
18-08-2021

URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/936d82ddf9a2 User: lana Date: 2016-05-04 18:39:50 +0000
04-05-2016

URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/936d82ddf9a2 User: psadhukhan Date: 2016-04-15 06:18:30 +0000
15-04-2016

The reason was we created topMargin JFormattedTextField once and added focusListener and ActionListener to this textfield but we overwrote the topMargin textField again by creating another instance and in that instance, we failed to add actionListener or focusListener, so when we tabbed out of topmargin field, focusLost() method was not called which would have called updateMargin() method to update the margins. Fix was to remove this erroneous instance creation and overwriting of topMargin textfield.
05-04-2016