• subscribe
  • twitter

MozSwing – A smart browser built on XUL and Java Swing

The MozSwing project seeks to integrate Mozilla’s XUL framework with Sun’s Java Swing GUI framework, the result is a prism-like browser called MozSwing that can be download as a JNLP(Java Network Launching Protocol) file.

Running the jnlp file will also run an extension-installer that will install platform and OS-specific XUL libraries in your Java Web Start cache. So your platform needs Java Web Start — which is automatically installed together with Java Runtime Environment (JRE).

The advantage in using the MozSwing approach is that, you have both rendering and scripting access from a Swing application to almost any XPCOM components that can be embedded in a Mozilla browser – browser plugins.
MozSwing plays Flash right out of the box, if flash is installed for Firefox.

Installing MozSwing in Windows is pretty easy, so far as you have JRE on and running.
In Ubuntu Hardy, JRE for Ubuntu may not be enough because Java Web Start launches the installer but fails to launch the jnlp file with the subsequent error “Java Web Start – Launch File Error”

MozSwing is triple-licensed: MPL 1.1, GPL 2.0and LGPL 2.1.
The MozSwing project is currently funded by Concord Consortium.

Authors Notes: Fear not jnlp files. The Java Web Start allows application to be started directly from the Internet using a web browser. Alternatively, an application could be started from local computer using a JNLP file (Java Network Launch Protocol file) which is often about 3-5Kb in size.

The Java Web Start caches the entire application locally on user’s computer. Thus, subsequent launches are almost instantaneous as all the required resources are already available locally. Every time the user starts the application, the Java Web Start component checks the application’s website to see if a new version is available, if so, it automatically downloads and launches it. So Java Web Start guarantees that the user is always running the latest version of the software eliminating complicated installation or upgrade procedures.
Download MozSwing


  1. Boh
    11:25 pm on September 13th, 2008

    Nice and simple browser.

  2. jean
    11:29 pm on September 13th, 2008

    I’ll stay with FF. thanks

  3. FoxEyes
    6:26 pm on September 19th, 2008

    Is there a way to hide the address bar? I’ve looked through the mailing list, but the solution they mention there did not work. (using the getToolbar/getStatubar functions and applying a setVisible(false) to them)

  4. Martin Kaba
    10:35 pm on September 19th, 2008

    @ FOXEYES: I’m sorry but I did not find much information on that, if you find out let us know. thanks

  5. Jörn Heid
    7:52 pm on September 24th, 2008

    @FOXEYES The MozillaPanel has a constructor where you can set the toolbar and statusbar to invisible.

    The work is really great and I hope more people will find this usefull software.

  6. Martin Kaba
    8:00 pm on September 24th, 2008

    @JöRD HEID: Many thanks for your contribution, i bet you this is great info, for me and certainly for FOXEYES and others.

  7. dabar
    8:59 pm on October 4th, 2008

    I think being able to easily embed it into other swing applications is the key role as far as I see. Then something i love about FF is the print function. Swing default HTML renderer is terrible and when you do getPrintable from Textpane, it prints terribly. so i think easy integration with other swing components is the key. BTW its great work and great news

  8. Collin
    7:08 pm on October 6th, 2008

    This looks like a heavyweight component? Is that true? How much access do you have to the rendering engine and underlying content?

  9. Martin Kaba
    10:40 am on October 7th, 2008

    @COLLIN; Heavyweight component? Why? You can download the source code if you want to get deeper.

  10. James
    7:01 pm on December 2nd, 2008

    @Collin: Yes, the component is heavyweight for now, which is unfortunate. I think that work is being done to try and make it a lightweight component, which would be great if it were possible.

  11. Mathew P
    2:06 am on December 31st, 2008

    The easiest way to remove the Toolbar is by getting the tool bar object from the MozillaPanel object and then call the removeAll() function.
    Here goes an example adapted to Example01_CreateWindow found under the org.mozilla.browser.examples package:

    MozillaWindow win = new MozillaWindow();
    MozillaPanel moz = win.getPanel();
    win.setSize(500, 600);
    JToolBar stBar = moz.getToolbar(); //this gets the JToolBar object, which is the browser’s toolbar
    stBar.removeAll(); //After you get a hold of this object you can manipulate it the way you’d like

  12. Martin Kaba
    6:52 pm on January 5th, 2009

    @ MATHEW: Thanks for your contribution.

  13. Mathew P
    2:02 am on January 6th, 2009

    Here goes the right way of doing it. Sorry for providing a not so good example. There isn’t a whole lot of documentation on MozSwing.

    MozillaPanel p = new MozillaPanel(MozillaPanel.VisibilityMode.FORCED_HIDDEN, MozillaPanel.VisibilityMode.FORCED_HIDDEN); //This will force to hide the tool bar and status bar
    MozillaWindow mw = new MozillaWindow(p);

  14. Martin Kaba
    12:30 am on March 17th, 2009

    A smart browser built on XUL and Java Swing; Mozswing http://tinyurl.com/5z2m2z

  15. Martin Kaba
    9:27 am on April 29th, 2009

    MozSwing – A smart browser built on XUL and Java Swing http://tinyurl.com/5z2m2z

  16. Martin Kaba
    9:28 am on April 29th, 2009

    MozSwing – A smart open source browser built on XUL and Java Swing http://tinyurl.com/5z2m2z

  17. marlon
    4:32 am on May 26th, 2009

    Does any one know where i can find a tutorial to get me started on this. How does one use the component in netbeans ide

  18. Ajith
    7:04 pm on July 4th, 2010

    I was working on a little project of mine and needed a way to embed Firefox in a Java UI Component. This is just the thing I need. Awesome work!
    Could someone tell me if MozSwing uses the default Firefox profile under ~/.mozilla/firefox/profiles? If not, how can I force MozSwing to use that profile? Alternatively, can MozSwing be setup to use a profile at a different location? My requirement is to be able to create and access cookies.