CSS Engine

Discussion in 'Java' started by howa, Mar 15, 2008.

  1. howa

    howa Guest

    Hi

    Are there any CSS engine library avaliable?

    Such as I have a input HTML:

    <p class="hidden"> Hidden </p>
    <p> Show </p>

    and a CSS file:

    p.hidden { display:none:}

    and I can use the engine to render the output as:

    Show



    Any recommendation?

    Thanks.
    howa, Mar 15, 2008
    #1
    1. Advertising

  2. On Mar 15, 6:57 pm, howa <> wrote:
    ...
    > Are there any CSS engine library avaliable?


    Swing components will render styled HTML, to an extent..

    <sscce>
    import javax.swing.*;

    class ExampleCSS {

    public static void main(String[] args) {
    String content =
    "<html>" +
    "<head>" +
    "<style type='text/css'>" +
    ".hidden { display: none; }" +
    ".invisible { visibility: hidden; }" +
    ".red { color: red; }" +
    "</style>" +
    "</head>" +
    "<body>" +
    "<p class='hidden'> Hidden </p> " +
    "<p class='invisible'> Invisible </p> " +
    "<p class='red'> I see red </p> " +
    "";
    JLabel render = new JLabel(content);
    JOptionPane.showMessageDialog(null, render);
    }
    }
    </sscce>

    Interestingly, neither the display nor visibility
    attributes seems to be supported in Java 1.6.

    > Any recommendation?


    1) Using Swing components. Keep the HTML as
    simple as practical, then load it using Java
    and remove the invisible elements before passing
    it on to a Swing component.

    2) The JDIC thing that allows you to 'embed' a
    browser in an application.

    --
    Andrew T.
    PhySci.org
    Andrew Thompson, Mar 15, 2008
    #2
    1. Advertising

  3. howa

    Roedy Green Guest

    Roedy Green, Mar 15, 2008
    #3
  4. howa

    howa Guest

    On 3$B7n(B15$BF|(B, $B2<8a(B4$B;~(B54$BJ,(B, Andrew Thompson <> wrote:
    > On Mar 15, 6:57 pm, howa <> wrote:
    > ...
    >
    > > Are there any CSS engine library avaliable?

    >
    > Swing components will render styled HTML, to an extent..
    >
    > <sscce>
    > import javax.swing.*;
    >
    > class ExampleCSS {
    >
    > public static void main(String[] args) {
    > String content =
    > "<html>" +
    > "<head>" +
    > "<style type='text/css'>" +
    > ".hidden { display: none; }" +
    > ".invisible { visibility: hidden; }" +
    > ".red { color: red; }" +
    > "</style>" +
    > "</head>" +
    > "<body>" +
    > "<p class='hidden'> Hidden </p> " +
    > "<p class='invisible'> Invisible </p> " +
    > "<p class='red'> I see red </p> " +
    > "";
    > JLabel render = new JLabel(content);
    > JOptionPane.showMessageDialog(null, render);
    > }}
    >
    > </sscce>
    >
    > Interestingly, neither the display nor visibility
    > attributes seems to be supported in Java 1.6.
    >
    > > Any recommendation?

    >
    > 1) Using Swing components. Keep the HTML as
    > simple as practical, then load it using Java
    > and remove the invisible elements before passing
    > it on to a Swing component.
    >
    > 2) The JDIC thing that allows you to 'embed' a
    > browser in an application.
    >
    > --
    > Andrew T.
    > PhySci.org



    What version of CSS is Java Swing supporting?


    I hope it can be supporting full CSS 2.0, e.g.

    DIV > P:first-child { display: none }

    Also, priority of styles is important, e.g.

    p {display: hidden; }
    #test {display: block; }

    if my paragraph is with ID = test, then it should not be hidden...


    Therefore, I am looking for fully functional CSS engine.

    Howard
    howa, Mar 15, 2008
    #4
  5. howa

    howa Guest

    On 3$B7n(B15$BF|(B, $B2<8a(B5$B;~(B02$BJ,(B, Roedy Green <>
    wrote:
    > seehttp://mindprod.com/jgloss/htmlrendering.html
    > for ways to render HTML (with css styles)
    > --
    >
    > Roedy Green Canadian Mind Products
    > The Java Glossaryhttp://mindprod.com


    i have looked this site before, but can't find any detail related to
    spec, e.g. supporting CSS 2.0 ect.

    Thanks anyway...

    Howard
    howa, Mar 15, 2008
    #5
  6. On Mar 15, 10:43 pm, howa <> wrote:
    > On 3$B7n(B15$BF|(B, $B2<8a(B4$B;~(B54$BJ,(B, Andrew Thompson <> wrote:

    ...
    > What version of CSS is Java Swing supporting?


    Not enough. Swing's support for CSS is very low.
    I am not sure of the spec. it claims to support,
    but even then I am pretty sure it makes no
    guarantees about supporting all of it.

    Roedy could probably tell you some funny stories
    about Swing's rendering of HTML as well.

    > Therefore, I am looking for fully functional CSS engine.


    Then look to..
    > > 2) The JDIC thing that allows you to 'embed' a
    > > browser in an application.


    BTW - a better way to post than 'bottom-posting'*
    is to post 'in-line with trimming'. Using ILWT
    you trim anything not immediately relevant to
    the reply (including signatures) and reply
    directly after each comment of interest.

    * Which, BTW, is still preferable to 'top-posting'.

    --
    Andrew T.
    PhySci.org
    Andrew Thompson, Mar 15, 2008
    #6
  7. On Mar 15, 10:58 pm, Andrew Thompson <> wrote:
    > On Mar 15, 10:43 pm, howa <> wrote:
    >
    > > On 3$B7n(B15$BF|(B, $B2<8a(B4$B;~(B54$BJ,(B, Andrew Thompson <> wrote:
    > > ..I am looking for fully functional CSS engine.

    >
    > Then look to..
    >
    > > > 2) The JDIC thing that allows you to 'embed' a
    > > > browser in an application.


    <https://jdic.dev.java.net/>
    "JDIC supports a variety of features such as
    embedding the native browser, launching .."

    --
    Andrew T.
    PhySci.org
    Andrew Thompson, Mar 15, 2008
    #7
  8. howa

    Roedy Green Guest

    On Sat, 15 Mar 2008 04:46:57 -0700 (PDT), howa <>
    wrote, quoted or indirectly quoted someone who said :

    >i have looked this site before, but can't find any detail related to
    >spec, e.g. supporting CSS 2.0 ect.


    Did you look at the link I gave you:

    http://mindprod.com/jgloss/htmlrendering.html

    Several of those rendering packages handle css.

    You are rendering HTML with CSS styles, not rendering CSS.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Mar 15, 2008
    #8
  9. howa

    Mark Space Guest

    Mark Space, Mar 15, 2008
    #9
  10. howa

    howa Guest

    On 3$B7n(B16$BF|(B, $B>e8a(B3$B;~(B38$BJ,(B, Mark Space <> wrote:
    > howa wrote:
    > > Hi

    >
    > > Are there any CSS engine library avaliable?

    >
    > Try this one:
    >
    > http://jrex.mozdev.org/


    wow...this is amazing, thanks!

    Howard
    howa, Mar 16, 2008
    #10
  11. howa

    Mark Space Guest

    howa wrote:
    > On 3$B7n(B16$BF|(B, $B>e8a(B3$B;~(B38$BJ,(B, Mark Space <> wrote:
    >> howa wrote:
    >>> Hi
    >>> Are there any CSS engine library avaliable?

    >> Try this one:
    >>
    >> http://jrex.mozdev.org/

    >
    > wow...this is amazing, thanks!


    I found that by typing "Java gecko" into Google and pressing the Search
    button. I guess this might be hard if you don't happen to know that
    Mozilla's layout-engine component is called Gecko.

    After looking at that project more carefully myself, it looks like the
    last update was in 2005. That's not a good sign. You should do some
    searching on your own ("Java gecko") but here's one that looks more up
    to date:

    <http://developer.mozilla.org/en/docs/JavaXPCOM:Embedding_Mozilla_in_a_Java_Application_using_JavaXPCOM>
    Mark Space, Mar 16, 2008
    #11
  12. howa

    howa Guest

    On 3$B7n(B17$BF|(B, $B>e8a(B1$B;~(B09$BJ,(B, Mark Space <> wrote:

    > After looking at that project more carefully myself, it looks like the
    > last update was in 2005. That's not a good sign. You should do some
    > searching on your own ("Java gecko") but here's one that looks more up
    > to date:
    >
    > <http://developer.mozilla.org/en/docs/JavaXPCOM:Embedding_Mozilla_in_a...>


    Thank you very much!

    Howard
    howa, Mar 16, 2008
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    4
    Views:
    709
    clintonG
    Dec 24, 2004
  2. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    695
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  3. tom watson

    print.css and screen.css

    tom watson, Sep 9, 2003, in forum: HTML
    Replies:
    1
    Views:
    458
    Jukka K. Korpela
    Sep 9, 2003
  4. Replies:
    1
    Views:
    369
    Sybren Stuvel
    Apr 10, 2006
  5. Sasha
    Replies:
    3
    Views:
    582
    Sasha
    May 22, 2007
Loading...

Share This Page