JEditorPane + CSS e as bordas nas tabelas

0 respostas
C

Bom dia,

Coloquei uma tabela html em um JEditorPane, usando css, consigo trocar as cores, os tipos de fontes, tudo certinho, mas to apanhando pra colocar bordas simples, simplesmente não aparecem.
Alguém já passou por esse problema, porque procurei no google e não acho nada para resolver essa minha questão.

Abaixo eu coloquei um exemplo simples com a idéia que tenho de implementar o CSS em um HTML comum, sem frescura.
Eu consigo trocar a cor da célula da tabela, etc etc, mas as bordas???

JEditorPane ep = new JEditorPane();

        String form = null;
        try
        {

                form = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
                form += "<head>\n";

                form += "<title> \"testet\" </title>\n";// +

                form += "</head>\n" +
                            "\n" +
                            "<body>\n" +
                            "<table>\n" +
                            "  <tr >\n" +
                            "    <td width=\"94\" height=\"20\">teste</td>\n" +
                            "    <td width=\"131\">ttt</td>\n" +
                            "    <td class=\"td1\" width=\"131\">aqui</td>\n" +
                            "  </tr>\n" +
                            "  <tr>\n" +
                            "    <td height=\"20\"> </td>\n" +
                            "    <td> </td>\n" +
                            "    <td> </td>\n" +
                            "  </tr>\n" +
                            "  <tr>\n" +
                            "    <td height=\"20\"> </td>\n" +
                            "    <td> </td>\n" +
                            "    <td> </td>\n" +
                            "  </tr>\n" +
                            "</table>\n";
                form +=  "</body>" ;

                HTMLEditorKit kit = new HTMLEditorKit();
                ep.setEditorKit(kit);

                StyleSheet styleSheet = kit.getStyleSheet();
                styleSheet.addRule("table { border:5px solid #990000; }" );
                styleSheet.addRule("table { border-collapse: collapse; }" );

                styleSheet.addRule("table {font-family: Courier,Helvetica,sans-serif; }");
                styleSheet.addRule("td.td1 {color: #ff0000;}");

                ep.setEditable( false );

                ep.setContentType( "text/html");

                ep.setText( form );
            }

            catch ( Exception e )
            {
                e.printStackTrace();
            }

            JFrame f = new JFrame( "TESTE CSS" );
            f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
           f.setSize( 800 , 600 );
           f.add( new JScrollPane( ep ) );
           f.setVisible( true );

Grato, Carlos

Criado 24 de julho de 2009
Respostas 0
Participantes 1