Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #5450

Re: JEditorPane html font size

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.gui
Subject Re: JEditorPane html font size
Date 2014-09-25 03:49 -0700
Organization Canadian Mind Products
Message-ID <sds72a98f36ks68jsv9cpnlkp29m3hr6oi@4ax.com> (permalink)
References <bvltqp$ut$1@minotaurus.cip.informatik.uni-muenchen.de> <TNudnXGpzadlJonJnZ2dnUU7-QGdnZ2d@giganews.com>

Show all headers | View raw


On Sat, 13 Sep 2014 16:49:44 -0500, andreadoria
<andreadoria22@hotmail.com> wrote, quoted or indirectly quoted someone
who said :

>html in a Java String use: 
>"<FONT style=\"font-size: 16pt\" COLOR=000064 FACE=SansSerif>"

It also understands css inline style.

e.g.

    /**
     * want a mono font so code will align.
     */
    private static final String stylesheet = "<style
type=\"text/css\">\n"
                                             +
"body{font-family:Consolas,\"Bitstream Vera Sans Mono\"," +
                                             "\"Lucida
Console\",monospace;}\n"
                                             +
"span.depth{color:blue;background-color:white!important;}\n"
                                             + "</style>\n";

    /**
     * DOCTYPE for generated HTML
     */
    private static final String DOCTYPE = "<!DOCTYPE HTML PUBLIC
\"-//W3C//DTD HTML 4.01 Transitional//EN\" " +
 "\"http://www.w3.org/TR/html4/loose.dtd\">";


    /**
     * where we display the code with unbalanced delimiter
     */
    private JEditorPane jep;


        sb.append( DOCTYPE );
        sb.append( "<html lang=\"en-CA\"><head>" );
        sb.append( stylesheet );   // in theory this should not work.
Only HTML 3.2 guaranteed to be supported.
        sb.append( "</head><body><pre><span>" );

jep.setContentType( "text/html" );
jep.setText( sb.toString() );
-- 
Roedy Green Canadian Mind Products http://mindprod.com
There are only two industries that refer to their customers as users.
~ Edward Tufte (born: 1942 age: 72)

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar


Thread

Re: JEditorPane html font size andreadoria <andreadoria22@hotmail.com> - 2014-09-13 16:49 -0500
  Re: JEditorPane html font size Roedy Green <see_website@mindprod.com.invalid> - 2014-09-25 03:49 -0700

csiph-web