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

ServiceUI.printDialog shows a superfluous dialog icon in the Windows 7 task bar

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • None
    • 6u10
    • client-libs
    • Cause Known
    • x86
    • windows_vista

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_12"
      Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
      Java HotSpot(TM) 64-Bit Server VM (build 11.2-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7100]

      A DESCRIPTION OF THE PROBLEM :
      The dialog shown by invoking

                        ServiceUI.printDialog(f.getGraphicsConfiguration(), 100, 100, services,
                              null, flavor, pras);

      does not behave like a standard modal JDialog -- specifically, under Windows 7, the print setup dialog appears as a distinct icon in the task bar (an entry that sits next to/underneath the parent's icon). When you click the icon in the taskbar, there are two items: the parent frame and the print dialog. With a standard JDialog, there is only one icon (as consistent with the behavior on previous releases of Windows).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      On Windows 7, run the attached program:

      java -cp . PrintTest

      Press the button that says "Click Me". Note the print dialog appears. Note that the Java application's icon in the task bar now has an extra appendage on the right side. This represents the dialog.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The extra appendage should not appear - the print dialog should behave like any other modal dialog.
      ACTUAL -
      The extra appendage appears (making it seem more like a non-parented JFrame, or a non-modal JDialog, rather than a modal dialog). When you click the icon, you see two choices (the parent frame and the print dialog).

      If you uncomment the "// This works properly" section of PrintTest.java, and comment out the ServiceUI line, you can see how the print dialog should behave.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /* Copyright 2009 The MathWorks, Inc. */

      import javax.print.ServiceUI;
      import javax.print.PrintService;
      import javax.print.PrintServiceLookup;
      import javax.print.DocFlavor;
      import javax.print.attribute.HashPrintRequestAttributeSet;
      import javax.print.attribute.PrintRequestAttributeSet;
      import javax.swing.*;
      import javax.swing.text.Document;
      import java.awt.event.ActionEvent;

      /**
       *
       */
      public class PrintTest {
          public static void main(String[] args) {
              final JFrame f = new JFrame("Frame");
              f.add(new JButton(new AbstractAction("Click Me") {
                  public void actionPerformed(ActionEvent e) {
                      PrintService[] services =
                              PrintServiceLookup.lookupPrintServices(null,
                                      new HashPrintRequestAttributeSet());
                      DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
                      final PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();

                      // This incorrectly shows an icon in the Windows 7 taskbar
                      ServiceUI.printDialog(f.getGraphicsConfiguration(), 100, 100, services,
                              null, flavor, pras);

                      // This works properly: only one icon in the Windows 7 taskbar
                      // JDialog d = new JDialog(f, "Dialog", true);
                      // d.setSize(300, 200);
                      // d.setVisible(true);
                  }
              }));
              f.pack();
              f.setLocationRelativeTo(null);
              f.setVisible(true);
          }
      }

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: