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

Print dialog box not updating Print Attribute settings for JTextField w/focus

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_01"
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

      Note: Java 5.0 update 3 to Java 5.0 update 11 has the same problem.

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

      A DESCRIPTION OF THE PROBLEM :
      The sun.print.ServiceDialog needs to update the attributes associated with the JTextField with focus when the user hits the Enter key to dismiss the Print dialog box, so the behavior matches the behavior when the user clicks on the "Print" button with the mouse or if focus moves to another component before the enter key is hit.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Bring up the sun.print.ServiceDialog print dialog box.

      Put focus on the JTextField controlling the last page of the page range.
      (Note: The same thing happens the starting page number, ending page number, left margin, top margin, right margin, bottom margin, the job name, or user name field) on the print dialog box .)

      Change the value.

      Hit the Enter key.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The Attributes associated with the JTextField that was changed should be updated to reflect the change to the field before the enter key was hit.

      If it was a 100 page report and the user changed the last page number from 100 to 1 and hit enter all 100 pages would print and our users keep compaining about all of the paper they are wasting.
      ACTUAL -
      The change that was made to the JTextField is not present in the attributes for the print job.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public static void main(String[] args) {
            // Setup a printer job to show the sun.print.ServiceDialog print dialog
              PrintRequestAttributeSet attribs = new HashPrintRequestAttributeSet();
              PrinterJob pj = PrinterJob.getPrinterJob();
              PageRanges range = new PageRanges(1, 9);
              attribs.add(range);

              // Display the print dialog box, and then display the values selected.
              // Repeat until the user hits cancel.
              while (pj.printDialog(attribs)) {
                  // Dump attributes to a buffer.
                  Attribute [] items;
                  PrintService ps = pj.getPrintService();
                  
                  // Dump print service attributes.
                  StringBuffer buf = new StringBuffer();
                  buf.append(ps.getName());
                  buf.append('\n');
                  items = ps.getAttributes().toArray();
                  for (int i = 0; i < items.length; i++) {
                      buf.append(items[i].getName());
                      buf.append('=');
                      buf.append(items[i].toString());
                      buf.append('\n');
                  }

                  // Dump the print request attributes.
                  items = attribs.toArray();
                  buf.append("====================\n");
                  for (int i = 0; i < items.length; i++) {
                      buf.append(items[i].getName());
                      buf.append('=');
                      buf.append(items[i].toString());
                      buf.append('\n');
                  }
                  
                   // Display the contents of the buffer.
                  JOptionPane.showMessageDialog(null, buf.toString());
              }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Change focus to another component before hit enter or click on the "Print" button with the mouse.

            psadhukhan Prasanta Sadhukhan
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: