JDK-4970112 : JTable printing completely broken - only the table grid is printed.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-12-17
  • Updated: 2003-12-19
  • Resolved: 2003-12-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b32Fixed
Related Reports
Relates :  
Description
Something in the fix to 4352983 has completely broken JTable printing. When printing a JTable, only the table grid is printed. This is not a bug in the new JTable printing code and happens regardless of which route you print a JTable.

To see the problem, compile the attached files and run Printing.java. Hit the "Print" button to print the table. The output will only have a grid and no cell data.

JTable does its cell printing through a CellRendererPane. My investigation began with CellRendererPane, and noticing that it calls g.create(int, int, int, int), I looked at the changes to the graphics "create" methods for 4352983. This led to sun.print.ProxyGraphics2D. The method "create(int, int, int, int)" was overridden as part of the fix to 4352983. The implementation follows:

public Graphics create(int x, int y, int width, int height) {
    return new ProxyGraphics2D((Graphics2D) mGraphics.create(x, y, width, height), mPrinterJob);
}

If these three lines are removed from ProxyGraphics2D.java, the problem goes away.

Fixing this bug is extremely important - without it, JTable printing is useless.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic tiger-beta FIXED IN: tiger-beta INTEGRATED IN: tiger-b32 tiger-beta
14-06-2004

SUGGESTED FIX http://sa.sfbay.sun.com/projects/swing_data/tiger/4970112/
11-06-2004

EVALUATION ###@###.### suggested to remove the mentioned code from ProxyGraphics2D. ---- Apologies, I failed to include the attachments when I filed this bug. The two files required to run the test in the description have now been attached. ###@###.### 2003-12-18
18-12-2003