views:

1074

answers:

5

Hi,

Now I am working on implementing a browser in Java. I need to display the contents of a website (provided a url-address) inside a JFrame window. Is there a simple way of doing that?

I tried JEditorPane, but it only supports HTML 3.2, so the contents of the website looks very weird.

Thanks

A: 

I have seen IntelliJ IDEA to use an embedded version of Mozilla/Firefox for showing web pages inside the IDE, so that is one way of showing web pages inside a Java Swing application. I don't know whether it is simple or not, but at least the pages are rendered correctly. Google knows this about embed mozilla in java.

Esko Luontola
A: 

If you can use SWT, you could try the SWT browser widget: http://www.eclipse.org/articles/Article-SWT-browser-widget/browser.html.

If you have to stick to Swing, there is WebWindow, which is a bit outdated AFAIK.

thSoft
+2  A: 

I have good experience with: http://djproject.sourceforge.net/ns/

Lets you cleanly embed a browser window within a Swing application, lets you manipulate the DOM and enables calling the host application from the browser itself.

BR, Oren.

Oren Yosifon
+1  A: 

Lobo is aiming for html 4 compliance.

http://lobobrowser.org/java-browser.jsp

One could argue that the rendering aspect of a browser is one of the most, if not the most, challenging aspects of developing a browser. (Networking, thread management, security sandbox, etc. are all pretty much available out of the box on the JVM ...)

So, if you're not up to writing your own components for dealing with correctly rendering documents based on xhtml, css, and javascript (not to mention various common plugins such as flash), then why not consider contributing to an open source effort such as lobo?

+1  A: 

You should look at this question.

We use JDIC and it runs very well on many platforms. The latest version was renamed and dropped many features (platform compatibility). But version 0.9.5, I think, works without problems.

Also there are plans for Web-kit based component integrated into swing. Don't remember the name of the project.

Vitaly Polonetsky
It's called JWebPane, it was announced here - http://weblogs.java.net/blog/alex2d/archive/2008/12/jwebpane_projec_1.html - but not yet released.
Patrick Wilkes