Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

CSS Engine

Thread view: 
howa - 15 Mar 2008 08:57 GMT
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.
Andrew Thompson - 15 Mar 2008 09:54 GMT
...
> 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
howa - 15 Mar 2008 12:43 GMT
> ...
>
[quoted text clipped - 44 lines]
> 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
Andrew Thompson - 15 Mar 2008 12:58 GMT
..
> 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 - 15 Mar 2008 13:03 GMT
> > ..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
Roedy Green - 15 Mar 2008 10:02 GMT
see http://mindprod.com/jgloss/htmlrendering.html
for ways to render HTML (with css styles)
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

howa - 15 Mar 2008 12:46 GMT
On 3月15日, 下午5時02分, Roedy Green <see_webs...@mindprod.com.invalid>
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
Roedy Green - 15 Mar 2008 19:13 GMT
>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.
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Mark Space - 15 Mar 2008 20:38 GMT
> Hi
>
> Are there any CSS engine library avaliable?

Try this one:

http://jrex.mozdev.org/
howa - 16 Mar 2008 12:02 GMT
> > Hi
>
[quoted text clipped - 3 lines]
>
> http://jrex.mozdev.org/

wow...this is amazing, thanks!

Howard
Mark Space - 16 Mar 2008 18:09 GMT
>>> Hi
>>> Are there any CSS engine library avaliable?
[quoted text clipped - 3 lines]
>
> 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_Appli
cation_using_JavaXPCOM
>
howa - 16 Mar 2008 19:26 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.