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

Java 1.4.2_02 printing failing/is very slow on code which works fine on 1.3.1 on

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.4.2_02
    • client-libs
    • None
    • x86
    • windows_nt

      Customer has a java swing application running fine on 1.3.1. Since upgrading to 1.4.2_02, printing has been very slow and they encounter this problem.

      The problem manifests itself in inability to print. Printer Status dialog would show that document is being spooled, but it never finishes spooling. "Killing" JVM releases the document, and it prints
      successfully. After several attempts to print, printing from other applications becomes affected. For example, printing from Notepad results in error message "The Handle is Invalid". The only solution after that is to re-boot the machine.

      The printouts are text only (there is no graphics) - basically, trade information in a tabular format.

      There is nothing fancy about them. The application is a standalone Swing Java application, so they are using Java printing API. As far as fonts are concerned, they are using common ones - Serif and SanSerif.

      Here are their questions:
      a) What DLLs are responsible for communication between Swing application and OS / printer driver?
      b) Did any of those DLLs change from JRE 1.3.1 and JRE 1.4.2?
      c) We get PrintJob by using getToolkit().getPrintJob(), and it seems to give us a "bad" printer handle that causes spooling to hang. What are Sun's recommendation on getting and using PrintJob class?
      d) Were any of the printing classes deprecated or taken out for 1.4.2 release, since JDK 1.4.2 introduced new Printing API?

      Here is their test case:
      ---------------------------------------------

      import java.awt.*;
      import java.awt.event.*;

      public class PrintingTest
          extends Frame
          implements ActionListener{
          public PrintingTest() {
              super("Printing Test");
              Button b = new Button("Print");
              b.setActionCommand("print");
              b.addActionListener(this);
              add("Center", b);
              pack();
          }

          public void actionPerformed(ActionEvent e) {
              String cmd = e.getActionCommand();
              if (cmd.equals("print")) {
                  PrintJob pjob = getToolkit().getPrintJob(this,
                                     "Printing Test", null, null);
                  if (pjob != null) {
                     for (int page = 0 ; page < 2; page++ ) {
                        Graphics pg = pjob.getGraphics();
                        Point currentPrintPosition;
                        currentPrintPosition = new Point(0,0);
                        currentPrintPosition.move(20,35);
                        if (pg != null) {
                           pg.setColor(Color.black);
                           pg.setFont(new Font("SanSerif", Font.BOLD, 8));
                           for (int i = 0; i < 3; i++) {
                              pg.drawString("Hello World", currentPrintPosition.x,
                              currentPrintPosition.y);
                              currentPrintPosition.x += 20;
                              currentPrintPosition.y += 35;
                           }
                           pg.dispose(); // flush page
                        }
                     }
                     pjob.end();
                  }
                  System.exit(0);
              }
          }
          public static void main(String args[]) {
              PrintingTest test = new PrintingTest();
              test.show();
          }
      }

      This only affects Windows NT boxes, the customer has Windows 2000 and XP, are not affected.

      ###@###.### 2003-12-18

            prssunw Prs Prs (Inactive)
            fchoong Fui-Shien Choong (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: