FULL PRODUCT VERSION :
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Versi��n 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
JTextPane doesn't wrap lines with long words (at least by default) in Java 7.
In previous Java versions (at least 1.3.x to 1.6.x), the default observed line wrapping behaviour for JTextPane was: split into lines at spaces if possible, and if not possible (because there is a very long word that doesn't fit in a single line) then split at some point in the middle of the word.
In 1.7.0_02, the observed behaviour is: split into lines at spaces if possible, but if not possible don't split. Instead, extend the size of the JTextPane (for example, if it's inside a JScrollPane, a horizontal scrollbar will appear).
This breaks programs that were relying in the previous behaviour (for example, when displaying a JTextPane with some text and a long strand of DNA, or a long number, this is important).
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a JScrollPane to scroll a JTextPane. Place it into a JFrame with some size (e.g. 200x200).
2. Execute it on 1.7. Select the text pane. Type some short words. Then type a very long word. (optionally, compare it with the behaviour in 1.6)
The full source code to do this is below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect the long word to be split into lines, as in previous versions of Java.
The long word is not split into lines: instead, a horizontal scrollbar appears.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class WrappingTest extends JFrame
public static void main ( String args )
public WrappingTest ()
JTextPane jtp = new JTextPane();
JScrollPane jsp = new JScrollPane(jtp);
---------- END SOURCE ----------