CSS Engine

H

howa

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

Andrew Thompson

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

howa

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.


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
 
H

howa

seehttp://mindprod.com/jgloss/htmlrendering.html
for ways to render HTML (with css styles)

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
 
A

Andrew Thompson

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..
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'.
 
M

Mark Space

howa said:
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/doc...Mozilla_in_a_Java_Application_using_JavaXPCOM>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top