-
Bug
-
Resolution: Incomplete
-
P3
-
None
-
7
-
x86
-
windows_7
FULL PRODUCT VERSION :
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) Client VM (build 23.2-b09, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When displaying a table using StyleSheet rules, the "border-collapse:collapse" rule works as expected for Java 6, but not Java 7, where it appears to be ignored.
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the StyleTester class described below. Run it with Java 6 and Java 7 to see the differences.
Note: My test case was compiled with Java6u32.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Table cells should share the same border.
ACTUAL -
With Java 7, borders are separated as though the "border-collapse:collapse" style was never specified.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package style;
import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
public class StyleTester {
static public void main(String[] args) throws Exception {
StyleTester tester = new StyleTester();
tester.display();
while (tester.dlg.isVisible()) {
Thread.sleep(100);
}
System.exit(0);
}
private JDialog dlg;
private HTMLEditorKit createCustomEditorKit() {
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet sheet = kit.getStyleSheet();
sheet.addRule("table.symbol { border-collapse:collapse; }");
sheet.addRule("table.symbol td { border-style:solid; border-width:thin; }");
return kit;
}
public void display() {
final JEditorPane pane = new JEditorPane("text/html", null);
pane.setEditorKit(createCustomEditorKit());
pane.setText(createDocument());
pane.setOpaque(false);
JOptionPane p = new JOptionPane(pane, JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION);
dlg = p.createDialog(null, "Style Tester");
dlg.pack();
dlg.setVisible(true);
}
private String createDocument() {
StringBuilder bob = new StringBuilder("<table class=\"symbol\"> <caption>Java: ");
bob.append(System.getProperty("java.version"));
bob.append("</caption>");
for (int i=1; i<6; i++) {
bob.append(String.format("<tr><td>Key %1$d</td><td>Value %1$d</td></tr>", i));
}
bob.append("</table>");
return bob.toString();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The "border-spacing: 0pt" rule produces the desired effect in both Java 6 and 7.
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) Client VM (build 23.2-b09, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When displaying a table using StyleSheet rules, the "border-collapse:collapse" rule works as expected for Java 6, but not Java 7, where it appears to be ignored.
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the StyleTester class described below. Run it with Java 6 and Java 7 to see the differences.
Note: My test case was compiled with Java6u32.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Table cells should share the same border.
ACTUAL -
With Java 7, borders are separated as though the "border-collapse:collapse" style was never specified.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package style;
import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
public class StyleTester {
static public void main(String[] args) throws Exception {
StyleTester tester = new StyleTester();
tester.display();
while (tester.dlg.isVisible()) {
Thread.sleep(100);
}
System.exit(0);
}
private JDialog dlg;
private HTMLEditorKit createCustomEditorKit() {
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet sheet = kit.getStyleSheet();
sheet.addRule("table.symbol { border-collapse:collapse; }");
sheet.addRule("table.symbol td { border-style:solid; border-width:thin; }");
return kit;
}
public void display() {
final JEditorPane pane = new JEditorPane("text/html", null);
pane.setEditorKit(createCustomEditorKit());
pane.setText(createDocument());
pane.setOpaque(false);
JOptionPane p = new JOptionPane(pane, JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION);
dlg = p.createDialog(null, "Style Tester");
dlg.pack();
dlg.setVisible(true);
}
private String createDocument() {
StringBuilder bob = new StringBuilder("<table class=\"symbol\"> <caption>Java: ");
bob.append(System.getProperty("java.version"));
bob.append("</caption>");
for (int i=1; i<6; i++) {
bob.append(String.format("<tr><td>Key %1$d</td><td>Value %1$d</td></tr>", i));
}
bob.append("</table>");
return bob.toString();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The "border-spacing: 0pt" rule produces the desired effect in both Java 6 and 7.