Aveen
Aveen

Reputation: 81

How to display html in a java application?

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

Upvotes: 2

Views: 17981

Answers (5)

m_vitaly
m_vitaly

Reputation: 11952

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.

Upvotes: 1

alphazero
alphazero

Reputation: 27234

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?

Upvotes: 1

Oren Yosifon
Oren Yosifon

Reputation: 927

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.

Upvotes: 4

thSoft
thSoft

Reputation: 22660

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.

Upvotes: 0

Esko Luontola
Esko Luontola

Reputation: 73625

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.

Upvotes: 0

Related Questions