Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6206286
Votes 0
Synopsis JEditorPane does not render BGCOLOR in an HTML TABLE
Category java:classes_swing
Reported Against
Release Fixed mustang(b53)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 4174871 , 4174874
Submit Date 09-DEC-2004
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
 customer  Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
The BGCOLOR attribute of an HTML TABLE in JEditorPane is not rendered.

I think that this is due to a change in TableView between 1.4.2 and 1.5.

The paint method of javax.swing.text.html.TableView included the line
 painter.paint(g, a.x, a.y, a.width, a.height, this);
But this is now:
 for (int i = borderWidth; i > 0; i--) {
  painter.paint(g, a.x + i, a.y + i, a.width - 2 * i, a.height - 2 * i, this);
 }

I think the loop condition should be "i >= 0" instead of "i > 0".


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set up JEditorPane like this:
JEditorPane editorPane =
            new JEditorPane("text/html",
                "<HTML><TABLE bgcolor='red'>" +
                "<TR><TD>Background should be red</TD></TR>" +
                "</TABLE></HTML>");


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The background of the text should be red.
ACTUAL -
The background was white.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

public class TableViewBug extends JFrame
{
    public TableViewBug()
    {
        super("Table View Bug");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public void display()
    {
        JEditorPane editorPane =
            new JEditorPane("text/html",
                "<HTML><TABLE bgcolor='red'>" +
                "<TR><TD>Background should be red</TD></TR>" +
                "</TABLE></HTML>");
        getContentPane().add(editorPane);
        pack();
        setVisible(true);
    }

    static public void main(String args[])
    {
        TableViewBug tableViewBug = new TableViewBug();
        tableViewBug.display();
    }
}

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

CUSTOMER SUBMITTED WORKAROUND :
Apply the BGCOLOR attribute to the TR element instead of the TABLE
  xxxxx@xxxxx   2004-12-09 10:36:45 GMT
Work Around
N/A
Evaluation
swing-html support html3.2
<table bgcolor> was introduced in html 4.x
closing as duplicate of 

4296022 html4.x support within a JEditorPane
  xxxxx@xxxxx   2005-04-14 02:37:14 GMT
This bug was introduced by the fix for 
4174871: JEditorPane ignores table border size
4174874: JEditorPane ignores CELLSPACING attribute in TABLE tag 

>I do not understand why we call painter.paint() inside a cycle -- does

That was a cryptic way to paint borders with width wider than 1. (introduced by those fixes)

The suggested fix is here:
http://sa.sfbay.sun.com/projects/swing_data/mustang/6206286.1
Posted Date : 2005-08-29 19:57:20.0
Comments
  
  Include a link with my name & email   

Submitted On 12-AUG-2005
HxA
Good Work!!
This already worked and we use it a lot of course.
Now it is broken and will prevent that we migrate to Java 1.5

Promising HTML 4 support for many years now And nothing in sight.


Submitted On 13-AUG-2005
idkush
Hi,

Thank you for the comment .
The bug was reopened and will be fixed in mustang.

Thanks,   
  Igor



PLEASE NOTE: JDK6 is formerly known as Project Mustang