3

I'm new to Java and Java Swing, and I'm creating an application that requires the presentation of web pages. I program for iOS a lot, and the simple solution here would be to load the page in a UIWebView. Is there an easy component for Java Swing? Or, is there an easy way to create something of the sort either in or outside of Swing?

I'm basically looking for something where you put in a URL, and a page loads in the application that looks like a normal page in a web browser.

dgund
  • 3,459
  • 4
  • 39
  • 64

2 Answers2

2

There's no single useful solution. There is the JEditorPane class, but it supports only HTML 4 and my experience with it is awful. For example, HTML comments showed up as plain-text.

If, however, you broaden the search to something outside Swing, there are plenty components that will do the job well. See this related question for a detailed discussion of these.

Community
  • 1
  • 1
K.Steff
  • 2,164
  • 3
  • 19
  • 25
  • I'm on a time constraint so I couldn't use this now. It seems good though, thank you I will use it next time. – dgund Jul 05 '12 at 16:23
2

If your Java program is a desktop application, the browse() method of java.awt.Desktop accepts a URI that may be obtained form a URL. The feature was added in Java SE 6. It's not embedded, but the user's chosen browser may be more appealing.

Addendum: See also How to open a URL in the default browser.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045