Would you like to learn how to make rich user interfaces with nothing more complicated than a text editor? Welcome to XUL, a subset of XML used to describe user interfaces. This article will get you started.
Before you start making XUL interface objects, such as windows with menus, toolbars, and so forth, you need to make a modification to your system environment variables (after Mozilla has been installed to the default location, of course). You can do this by using the DOS command line, or you can do it easily with the System applet on your Windows Control Panel. Iím assuming that you have Windows XP installed as your operating system here; if not, this section probably wont help you. XUL itself should still work, though, because this is a cross-platform technology.
I initially tried to do it using the command line method, which failed repeatedly (although I have no idea why), so I reverted to using the System applet method instead, and it worked the first time. To add the path variable to your system environment using the System method, just go to the System icon in the control panel, select the Advanced tab, and click on Environment Variables. Now click on the bottom New button; in the Variable Name field type "path" (without the quotation marks) and in the Variable Value field type "C:\Program Files\mozilla.org\Mozilla" (again, without the quotation marks). Make sure that this is typed as it appears here -- donít set the Name field to Path instead of path, for example, because there is already a Path variable present. Now click OK until the System box disappears and youíll be ready to go.
When producing XUL test files, in order to follow this article and in general, it is a good idea to use the DOS command line to execute the files. You can open the files from within Mozilla once the environment variable has been added correctly, but this will cram your window among the elements of Mozillaís interface, and will detract from your learning experience. Opening basic files via the Mozilla interface does not appear to give you any extra functionality, although some of the more advanced elements must be opened through Mozilla using a chrome URL. This will be discussed later on.
You can also create plugins and even entire applications using XUL, but there is far more work that needs to be done, including modifying Mozilla to get it to include your plugin when it launches. In those cases, you wouldnít need to use the command line. In development however, to execute a file, for example, called myFirstWindow.xul that was stored in a directory called XUL within the root directory, you would need to open a command line instance (by typing cmd in the run bar for those of you that donít already know) and type: "Mozilla Ėchrome file://C:/XUL/myFirstWindow.xul" without the quotation marks. You would get the Mozilla splash screen, and then a window would appear. As youíll need a directory to store your test XUL files in, you might as well make a XUL folder on the C: drive now.