JDK-6361986 : Line wrapping works opposite to what is shown on the screen, when printing JEditorPane text, WinXP
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-12-12
  • Updated: 2010-04-02
  • Resolved: 2006-01-04
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.
JDK 6
6 b66Fixed
Related Reports
Relates :  
Description
I am printing a RTF file and a simple text file through JEditorPane. I am noticing the following behaviors which are not compatible with what is shown on the screen.

1. RTF file loaded onto the JEditorPane line wraps the text properly on the screen when reducing/increasing the size of the pane. But when printing the text, the lines are not wrapped properly and they are truncated in the print out for the default paper.

2. Simple Text file loaded onto the JEditorPane does not line wrap automatically but when I print it out, it does line wrap in the print out. Not sure which one is the right behavior.

All the above behaviors are reproduced on Mustang-b62 with WinXP Prof. I am using default paper. Customer is likely to expect the screen behavior when printing the JEditorPane contents and would be good if this is made consistant.

I have attached a sample test with a rtf and a simple text file. Run the application passing the file name as the argument. Print the contents of JEditorPane and see how they are wrapped in the print out.

Comments
EVALUATION I think we should try to do wrapping all the time. That means we need to address the RTF case. Currently we set width for the printed component to be no less than preferred width. That is why printing RTF is not wrapped to the page width. (For html it works a bit different. html wraps to the width of the JViewport the text component is in) I suggest to set width for the printed component to the paper width. *** /tmp/geta14405 Wed Dec 14 17:42:30 2005 --- TextComponentPrintable.java Wed Dec 14 17:23:40 2005 *************** *** 557,566 **** JViewport viewport = new JViewport(); viewport.setBorder(null); viewport.setComponentOrientation(printShell.getComponentOrientation()); ! viewport.setSize(new Dimension(width, HUGE_INTEGER)); viewport.add(printShell); ! int textWidth = Math.max(printShell.getPreferredSize().width, width); ! printShell.setSize(new Dimension(textWidth, HUGE_INTEGER)); rendererPane.add(viewport); } --- 557,566 ---- JViewport viewport = new JViewport(); viewport.setBorder(null); viewport.setComponentOrientation(printShell.getComponentOrientation()); ! Dimension size = new Dimension(width, HUGE_INTEGER); ! viewport.setSize(size); viewport.add(printShell); ! printShell.setSize(size); rendererPane.add(viewport); }
14-12-2005

EVALUATION I am not sure the attached test case is the one the descripion talks about. It shows rtf as plain text and it wraps plain text. Could you please attach the correct test?
12-12-2005