United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6494356 Jeditorpane does not start up the html file
JDK-6494356 : Jeditorpane does not start up the html file

Details
Type:
Bug
Submit Date:
2006-11-16
Status:
Closed
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:

Sub Tasks

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
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).
                                     
2006-11-20
SUGGESTED FIX

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



Hardware and Software, Engineered to Work Together