-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6u3
-
x86
-
windows_xp
The JTextPane ignore CSS with Grouing Seletors ( http://www.w3.org/TR/REC-CSS2/selector.html#grouping ) in HTML text if there are no spaces in the comma separated list. In the CSS2 specification you can read that this is a comma separated list. Spaces are optional. This should be a small bug in the CSS parser. I see no solution for a workaround.
----------- Test Case Begins -----------------
import javax.swing.*;
import javax.swing.text.Document;
public class TestCssWithGrouping {
public static void main( String[] args ) throws Exception{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
final JTextPane text = new JTextPane();
frame.add( text );
String anyText = "<html>" +
"<head>" +
"<style type='text/css'> " +
//"H1, H2, H3 { background-color: #0000FF; }" + // working
"H1,H2,H3 { background-color: #0000FF; }" + // not working
"</style>" +
"</head><body> " +
"<h1>any text</h1>" +
"</body></html>";
text.setContentType( "text/html" );
Document doc = text.getDocument();
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
text.setText( anyText );
frame.setSize( 300, 200 );
frame.show();
}
}
--------------- Test Case Ends ---------------------
----------- Test Case Begins -----------------
import javax.swing.*;
import javax.swing.text.Document;
public class TestCssWithGrouping {
public static void main( String[] args ) throws Exception{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
final JTextPane text = new JTextPane();
frame.add( text );
String anyText = "<html>" +
"<head>" +
"<style type='text/css'> " +
//"H1, H2, H3 { background-color: #0000FF; }" + // working
"H1,H2,H3 { background-color: #0000FF; }" + // not working
"</style>" +
"</head><body> " +
"<h1>any text</h1>" +
"</body></html>";
text.setContentType( "text/html" );
Document doc = text.getDocument();
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
text.setText( anyText );
frame.setSize( 300, 200 );
frame.show();
}
}
--------------- Test Case Ends ---------------------