Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView-style Java component

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.

like image 381
dgund Avatar asked Aug 28 '26 08:08

dgund


2 Answers

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.

like image 100
trashgod Avatar answered Aug 30 '26 21:08

trashgod


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.

like image 36
K.Steff Avatar answered Aug 30 '26 23:08

K.Steff