JDK-6559929 : JEditorPane within a JScrollPane can throw Swing into an infinite loop
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u1
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-05-21
  • Updated: 2011-01-19
  • Resolved: 2007-07-16
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 7
7Resolved
Related Reports
Duplicate :  
Description
J2SE Version (please include all output from java -version flag):
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

Does this problem occur on J2SE 1.4.x or 5.0.x or 6.0?  Yes / No (pick one) 
Yes

Operating System Configuration Information (be specific):
Microsoft Windows XP [Version 5.1.2600]

JEditorPane within a JScrollPane can throw Swing into an infinite loop

1) Run Code
2) Enter some text (the word 'test' will do)
3) Swing now enters into an infinite loop, putting in the scrollbars, then removing them every iteration

import static javax.swing.JFrame.*;
import static javax.swing.JSplitPane.*;
import javax.swing.*;

public class Test {
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.add(new JSplitPane(HORIZONTAL_SPLIT, new JScrollPane(new JEditorPane("text/rtf", null)), new JLabel()));
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
}

Comments
EVALUATION The effect is caused by the incorrect minimum span calculation along x-axis in the javax.swing.text.ParagraphView. It's zero, but in reality GlyphView will not wrap if the available space is not sufficient to fit a single character. So layout ends up repeatedly adding and removing vertical scrollbar when the viewport becomes too narrow after adding the scrollbar and the text doesn't fit without the scrollbar. The javax.swing.text.html.ParagraphView doesn't have this problem because its minimum span is non-zero (it's the width of the longest word within the paragraph). The problem of the correct minimum span calculation for the ParagraphView is already addressed in the 6423287, so I'm closing this as a duplicate.
16-07-2007

EVALUATION It looks like this problem is specific to JEditorPane I tested the test case with new JTextField(""), it works ok with new JEditorPane("text/plain", "") and JEditorPane("text/html", "") no problems either reassigned to the text team
11-07-2007