8

Possible Duplicate:
Is there a way to embed a browser in Java?

How can I embed a browser in a Java based desktop application? Can I communicate with the embedded browser directly (not via localhost)... such as loading html text, capturing onclick events, getting form values?

Thanks

2
  • do you want an actual embedded browser, or do you want to programmatically navigate HTML pages? Commented Sep 21, 2009 at 14:14
  • May want to checkout github.com/rogerwang/node-webkit Commented Jun 28, 2014 at 14:53

6 Answers 6

6

check out Eclipse, it has an embedded browser which is configurable by the user (they support multiple browsers).

you can probably embed their browser even if you use an AWT based application using the AWT_SWT bridge.

this article may help you get started.

Sign up to request clarification or add additional context in comments.

1 Comment

Is there a stand alone version of this?
6

Swing JEditor pane is able to display HTML.

Check http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JEditorPane.html

Also here in SO is a more detailed answer to this topic:

https://stackoverflow.com/questions/48249/java-embedding-a-web-browser-pane

1 Comment

The SO link suggests JWebPane, but you suggest JEditor. I do not think they are the same thing. Thanks for the links, I will investigate both.
3

You can build a very primitive browser using JEditorPane. You can listen to Hyperlink events, but javascript or getting form values isn't possible.

Comments

2

Lobo is a Java web browser which can be embedded into Swing applications.

It supports HTML 4, CSS 2, and Javascript, which is more up-to-date compared to the JEditorPane which only supports HTML 3.2.

For some ideas on what is possible, the Lobo Browser API documentation should provide an idea of what is possible to do with Lobo. In particular, the org.lobobrowser.gui has a BrowserPanel class which is a subclass of JPanel, so it can be directly embedded in Swing applications.

For example, the BrowserPanel.navigate method can be used to jump to web pages, and there are many Listeners which can capture events which occur in the browser.

1 Comment

The original Lobo project seems to be dead. Here is a fork: sourceforge.net/projects/loboevolution
2

You could also try the JWebBrowser from DJ Native Swing: http://djproject.sourceforge.net/ns

Comments

1

You could try JxBrowser library: http://www.teamdev.com/jxbrowser/features/

For example to embed Mozilla browser into your Java Swing application you just need to do the following code:

Browser browser = BrowserFactory.createBrowser(BrowserType.Mozilla);

JFrame frame = new JFrame();

frame.add(browser.getComponent(), BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

browser.navigate("http://www.google.com");

4 Comments

this is not free to use :/
Update: since 4.0 version JxBrowser integrates with Chromium engine only on all platforms including Mac OS X, Linux and Windows.
@Vladimir coudl you provide me link for jar file and tutorial for jxBrowser. If you have any tutorial which enable to read epubfile/epublib using jxBrowser please mentioned it.
@RaviPrajapati JxBrowser JARs you can download from teamdev.com/jxbrowser On this web page you can find links on JxBrowser documentation and examples.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.