Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6626034

JTextPane ignore CSS with Grouing Seletors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6u3
    • client-libs

      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 ---------------------

            peterz Peter Zhelezniakov
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: