JDK-6308772 : Landscape printing problem - VM crash or incomplete print
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2005-08-10
  • Updated: 2011-02-16
  • Resolved: 2005-08-31
Related Reports
Duplicate :  
Relates :  
Description
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

Comments
EVALUATION Note that this was closed as a dup of 4924298 but that is a dup of 6186524 : Swing Basher throws an expection(EXCEPTION_ACCESS_VIOLATION) in windows XP professional
20-04-2006

EVALUATION Has the same symptoms as 4924298. Marking as dup.
31-08-2005

EVALUATION Works fine for me when printing to file on XP. Perhaps this relates to a specific driver? Re-assigning to 2D.
10-08-2005