JDK-6494356 : Jeditorpane does not start up the html file
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-11-16
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
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 JDK 7
6u1Fixed 7 b07Fixed
Description
FULL PRODUCT VERSION :
 1.6.0-rc-b100

A DESCRIPTION OF THE PROBLEM :
Jeditorpane does not start up the html file. May be a problem with css? Under 1.5.0 these run fine. But under 1.6.0 sometimes I am greeted by a black dos screen.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Stack trace attached

---------- BEGIN SOURCE ----------
Java File

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;


public class MyEditorPane extends JEditorPane{
   
    private static MyEditorPane editorPane;
   
    private MyEditorPane(){
       
        setContentType("text/html");
        final HTMLEditorKit editor =(HTMLEditorKit) this.getEditorKit();
        StyleSheet styles = new StyleSheet();
        editor.setStyleSheet(styles);
        setEditorKit(editor);
        try{
            styles.importStyleSheet( 
MyEditorPane.class.getResource("Html.css"));
        }catch (Exception ex){
            System.out.println(ex);
        }
        setEditable(false);
    }
   

   
    public static  MyEditorPane getInstance() {
        if (editorPane == null) {
            editorPane = new MyEditorPane();
        }
        return editorPane;
    }
   

    public static void main(String[] args) {
       
        final JFrame frame = new JFrame();
        frame.setTitle("First");
        frame.setSize(new 
Dimension(Toolkit.getDefaultToolkit().getScreenSize().width,600));
        MyEditorPane.getInstance();
         try{
            
MyEditorPane.editorPane.setPage(MyEditorPane.class.getResource("./HTML.html"));
        }
        catch (Exception exc) {}       
        frame.setContentPane(MyEditorPane.editorPane);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
    }
   
}

CSS file

p {
text-decoration:none;
text-indent:0;
font-weight:normal;
padding-top:0;
margin-top:0;
vertical-align:top;
font-style:normal;
padding-right:0;
padding-bottom:10;
font-size:18;
font-family:Verdana,Comic Sans MS,Lucida Bright,SansSerif;
padding-left:0;
margin-left:40;
color:#000000;
text-align:left;
}

h1 {
text-decoration:normal;
font-size:150%;
text-indent:0;
font-weight:bold;
padding-top:0;
margin-top:10;
margin-bottom:0;
vertical-align:top;
font-style:normal;
padding-right:0;
padding-bottom:10;
font-family:Verdana,Comic Sans MS,Lucida Bright, SansSerif;
padding-left:0;
color:#000000;
margin-left:0;
text-align:center;
margin-bottom:6;
margin-right:0;
}

hr{
margin-top:50;
margin-bottom:0;
margin-left:100;
padding-left:10;
padding-bottom:50;
color:#000000;
}

HTML file

<html>
<head>
<title>Test</title>
</head>
<body bgcolor="#FFFFFF">
<h1>Test</h1>
  <blockquote>
<hr align = "center" noshade>
<p>Test
<p>Test
<p>Test
<hr noshade>
</blockquote>
</body>
</html>


---------- END SOURCE ----------


REPRODUCIBILITY :
This bug can be reproduced often.

Release Regression From : 5.0u9
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
SUGGESTED FIX Webrev: http://javaweb.sfbay/jcg/1.7.0-dolphin/swing/6494356/
28-11-2006

EVALUATION The problem is that in some cases BoxView.layout() is called with negative width and/or height. The current code in the method FlowView.FlowStrategy.layout() is not prepared to deal with this situation (negative view span values) and cycles. The code that *was* able to repair from this was apparently removed from FlowView in version 1.45 somewhere between mustang builds 06 and 09. The fix is trivial, just don't call BoxView.layout() with negative arguments (this contract btw. is specified in the method documentation).
20-11-2006