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

Landscape printing problem - VM crash or incomplete print

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • client-libs
    • 2d
    • x86
    • windows_2000

      FULL PRODUCT VERSION :
      java version "1.5.0_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

      FULL OS VERSION :
      Microsoft Windows 2000 ver 5.00.2195 Service Pack 3

      A DESCRIPTION OF THE PROBLEM :
      When printing a JTable in landscape VM crashes; or partially prints; or print is missing or garbage.

      This behavior occurs if I create my own Printable object and do painting myself in the print method or if I call the JTable print method.

      The attached testcase should help in reproducing the bug. It has
      crashed the VM several times. I can't recall it ever printing all three pages
      correctly. You can control the print density by expanding the columns since
      it automatically scales the print down.

      The tests were performed on a HP LaserJet 8000 series printer connected
      to a 10Gb Ethernet network. It is printing PostScript format.

      As far as I know the problem does not occur when:
        - run as an Applet
        - portrait layout is used
        - the print is output to a file and printed w/ a utility

      When I print to a file using the test program I get a lot of garbage. This is the program I used to print the test file.

      Perhaps there is a threading problem when rotating the image in
      landscape layout or a buffer issue or several errors.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: No

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the attached test case

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The table object should print as it does on the screen.
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Attached seperatly

      ---------- BEGIN SOURCE ----------

      import java.util.*;
      import java.net.*;
      import java.awt.*;
      import java.text.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.table.*;
      import javax.print.*;
      import javax.print.attribute.*;
      import javax.print.attribute.standard.*;
      import javax.print.event.*;

      public class MainFrame extends JFrame implements ActionListener {
        JMenuBar menuBar;
        JMenu options;
      JMenuItem printAlloc;

        JTable testTab;
        TestModel allocModel = new TestModel();
        JTabbedPane tabbedPane = new JTabbedPane();

        public MainFrame () {
          super("Print Test");

          addWindowListener (new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
      System.exit(0);
            }
          });

      testTab = new JTable();
      testTab.getTableHeader().setReorderingAllowed(false);
      testTab.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      testTab.setPreferredScrollableViewportSize(new
      Dimension(500, 70));
      testTab.setColumnSelectionAllowed(true);
      testTab.setCellSelectionEnabled(true);
          testTab.setModel(allocModel);

          JScrollPane jspan = new JScrollPane(testTab);
          jspan.getViewport().setPreferredSize(new Dimension(500, 300));

          //Create the scroll pane and add the table to it.
          tabbedPane.addTab("Allocations", null, jspan, "Identify Current Allocation");

          menuBar = new JMenuBar();
          setJMenuBar(menuBar);

          JMenu printing = new JMenu("Printing");
          printAlloc = new JMenuItem("Print Allocations");
          printing.add(printAlloc);

          JMenu actions = new JMenu("Actions");
          actions.add(printing);
          menuBar.add(actions);

      printAlloc.addActionListener(this);

      Container cp = getContentPane();

      cp.setLayout(new GridLayout(1, 1));
          cp.add(tabbedPane);

          setBounds(20, 20, 700, 800);
          setVisible(true);
      }

      public void actionPerformed(ActionEvent ae) {
      MessageFormat header = new MessageFormat("Bug Testing");
      Object [] arguments = {new Date(System.currentTimeMillis())};

      String result = MessageFormat.format("{0,date},",arguments);
      System.out.println("printing..");
      System.out.println(result);
          MessageFormat footer = new MessageFormat("result");
      boolean showPrintDialog = true;
      boolean interactive = true;
      PrintRequestAttributeSet attr = new
      HashPrintRequestAttributeSet();
      // set the page orientation
      attr.add(OrientationRequested.LANDSCAPE);
      try {
      System.out.println("printing..");
      testTab.print(JTable.PrintMode.FIT_WIDTH, header,
      footer, showPrintDialog, attr, interactive);
      System.out.println("printing.. done");
      }
      catch(Exception e) {
      e.printStackTrace();
      }
      }

        public static void main (String[] args) {
      new MainFrame();
        }
      }

      class TestModel extends AbstractTableModel {

      String alpha =
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

        public TestModel() {
          super();
        }

        public int getColumnCount() {
          return 15;
        }
       
        public int getRowCount() {
          return 400;
        }

        public Object getValueAt(int row, int col) {
      return(alpha);
        }

        public Class getColumnClass(int col) {
          try {
      return getValueAt(0, col).getClass();
          }
          catch (Exception e) {
            return "Test".getClass();
          }
        }

      public boolean isCellEditable(int row, int col) {
      return false;
      }

      public void setValueAt(Object value, int row, int col) {
      }
      }
      ---------- END SOURCE ----------

      REPRODUCIBILITY :
      This bug can be reproduced often.

      CUSTOMER SUBMITTED WORKAROUND :
      Must print portrate

            jgodinez Jennifer Godinez (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: