I’m currently putting together an application that will be implemented in SWT/JFace/RCP/Java, Swing/Spring Rich/Java, and Cocoa/Objective-C. I’m doing to see what they will look like on OS X, plus to learn a little more about the RCP, a lot more about Spring Rich, and a whole lot more about Cocoa/Objective-C.
One of the interesting aspects of this application is that it will have a Browser embedded in it.
I looked first at the SWT sources, since I’ve use the Browser component in Eclipse. In fact, you can drag an .html file from the Finder and drop into the Package Explorer or the Resource Navigator, then double-click on the .html file to open it in the Browser. This shows the decent integration Eclipse has on OS X, but there are still some holes, such as dragging out of an SWT app which isn’t supported yet. By the way, if you care about that, you can register with the Eclipse Bugzilla and then vote for it. Anyways, the Browser integration in Eclipse is quite nice, as it embeds the WebKit (which is what Safari uses) in your SWT/JFace/RCP app. It has hooks for actions such as openURL, back, forward, stop, refresh, as well as listeners for state changes. The org.eclipse.swt.browser.Browser class in org.eclipse.swt.carbon_3.0.1 plug-in is quite clean. It doesn’t go directly against JNI, which always seemed ugly. It hides most (or all) of the native calls in the org.eclipse.swt.browser.WebKit class, which depends on the swt-webkit library I talked about in an earlier post.
I then searched around for a good Swing Browser component. I found the relatively new JDIC project, which was kicked off around the JavaOne 2004 timeframe. The acronym stands for JDesktop Integration Components, with JDesktop Integration Components, which when translated into English means: “let apps be more native”. This has a browser component, but doesn’t have one yet on OS X. In fact, most of the OS X port of JDIC is incomplete. However, I would give this a try on Windows, Linux, and Solaris.
Searching further, I ran across an integration of WebKit with AWT by Dmitry Markman. The code is not as clean as the SWT Browser code, but it looks like the JDIC-Mac team will probably adopt it and clean it up. However, if you try the sample app included, it works pretty much like the SWT Browser widget, since it uses the same WebKit. I think the SWT Browser still has better support for actions and state listeners, though. I’m looking forward to the JDIC-Mac browser though, as well as any Dock/menulet support they could offer.
By the way, there is a good article about using the SWT Browser widget at the Eclipse Corner.
UPDATE: [11/2/2004 10:52AM EST] I’ll be looking at embedded browser components (in Java of course) on Windows tomorrow.