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

New bugs in PrintJob in 1.1.5

XMLWordPrintable

    • 2d
    • 1.4
    • x86
    • windows_95, windows_nt



      Name: joT67522 Date: 12/12/97


      I've found PrintJob in v1.1.5 to be buggier
      than the one in v1.1.4. For example:
      (1) it won't print a simple Frame with 3 Buttons
      correctly.
      (2) it won't print a Canvas at all (gives a
      Java.Lang.NullPointerException).
      Please run the following program:

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

      class MainFrame extends Frame implements ActionListener
      {
          Button printWindowButton = new Button("PrintWindow");
          Button printCanvasButton = new Button("PrintCanvas");
          Button exitButton = new Button("Exit");
          
          public static void
          main (String argv[])
          {
              new MainFrame ();
          }

          public
          MainFrame ()
          {
              super ("PrintTest");
              
              setLayout(new FlowLayout());
              add(printWindowButton);
              add(printCanvasButton);
              add(exitButton);
              
              printWindowButton.addActionListener(this);
              printCanvasButton.addActionListener(this);
              exitButton.addActionListener(this);
              
              pack();
              show();
          }
          
          public void
          actionPerformed (ActionEvent e)
          {
              if (e.getSource() == exitButton)
              {
                  setVisible (false);
                  dispose ();
                  System.exit (0);
              }
              else if (e.getSource() == printWindowButton)
              {
                  PrintJob pjob = getToolkit().getPrintJob(this,"PrintWindow",null);
                  if (pjob == null) return;
                  Graphics pgraphics = pjob.getGraphics();
                  if (pgraphics == null) return;
                  printAll (pgraphics);
                  pgraphics.dispose();
                  pjob.end();
              }
              else if (e.getSource() == printCanvasButton)
              {
                  PrintJob pjob = getToolkit().getPrintJob(this,"PrintCanvas",null);
                  if (pjob == null) return;
                  Graphics pgraphics = pjob.getGraphics();
                  if (pgraphics == null) return;
                  PrintCanvas pCanvas = new PrintCanvas();
                  pCanvas.paint(pgraphics);
                  pgraphics.dispose();
                  pjob.end();
              }
          }
      }

      class PrintCanvas extends Canvas
      {
          public
          PrintCanvas ()
          {
              super();
          }
          
          public void
          paint (Graphics g)
          {
              g.drawString ("Hello Cruel World.", 50, 50);
          }
      }
      (Review ID: 21825)
      ======================================================================

            jgodinez Jennifer Godinez (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: