James Williams
LinkedInMastodonGithub

MozSwing with Griffon

Tags: Griffon

MozSwing is kinda has been in the back of my mind for a while now. We (the Griffon Team) even evaluated it for one of our early builds. But we thought, "JWebPane is going to be out soon and probably will be more lightweight than MozSwing(50MB)." Needless to say, JWebPane is no where to be found so I thought it would a good idea to reevaluate MozSwing.

Before you object and say your project can't accommodate an increase in size of 50MB, it won't be that much. Best case scenario, it would be 2MB, worse case is 24MB. The reason for the span in sizes is that MozSwing bundles xulrunner for all major platforms(Win32, Linux, OSX, and Solaris). If XULRunner is already on the machine, you only need 2MB of jars and it'll generally pick up whatever plugins you have installed for Firefox.

The demo app runs at this point but not in a Griffon context. It can't seem to find xulrunner without being told the path. I just set up an environment variable for it under XULRUNNER_HOME and overrode that line in MozillaConfig.

For those that are getting tense, you don't have to build MozSwing. Just open up the mozswing jar in your favorite archive manager, navigate down to the org/mozilla/browser and delete everything that starts with MozillaConfig. Grab MozillaConfig.java, drop in the src dir of your Griffon app and add/modify this line

private static File xulRunnerHome = new File(System.getenv().get("XULRUNNER_HOME"));

Now you can call new MozillaPanel() to create a browser panel and load("address") to load an address in that panel. And here is the photographic proof that it works:

Because of Linux's modular nature, you have to explicitly copy plugins from your Firefox installation to the XULRunner directory whereas Windows seems to pick up those plugins automatically. Plugin sitch is unknown on OS X or Solaris.

Mozswing http://sourceforge.net/projects/mozswing

Update: It is noteworthy to mention that JDIC has had a JDICplus project for a while integrating IE in Swing but because IE is dying and is mostly non-compliant to standards, I don't see it as a viable option.