Keller Technologies Inc.

  • Web Design
  • Web Hosting
  • Domains
  • skip to Navigation
  • skip to Search

Project Links

Home Source Code Build Instructions Rhino Integration Implementation Checklist

Parser Documentation

JavaDoc API (http://www.rj.pcblaze.com/downloads/xulparser/javadoc/) Casting Reference


Table of contents
1 XUL Parser Project

1.1 So why XUL?
1.2 License
1.3 Architecture
1.4 Usage
1.5 Events

1.5.1 But how do I talk with my Java code from JavaScript?

1.6 Future
1.7 Found a bug?

[edit]

XUL Parser Project

The current Sun GUI toolkit is a pain to use. All those menu.add() calls and the code is so messy. If you have an application with a complex layout, the GUI code can be almost unreadable. XUL Parser project attempts to correct these problems by providing a extensive XML GUI language from which you can build your Java GUI on. The language is based on the very popular XML User Interface Language (XUL) (http://www.mozilla.org/projects/xul/) developed by The Mozilla Foundation. XUL Parser also embeds the Eclipse SWT GUI toolkit, allowing you to use fast, native GUI for your Java applications.

With XUL, those evil layout bugs will be a thing of the past. Not only that, the language is so simple to use and read that it's basically like writing your GUI spec and programming it at the same time!

XUL Parser also implements DTD files, providing a easy alternative to .properties files for quick and easy XUL localizations.

[edit]

So why XUL?

XUL stands for the XML User Interface Language which is the XML GUI language used to program the Mozilla Firefox browser. What makes this language superior to other Java GUI XML languages is that it's already very popular and a constantly evolving specification. Over 3 years of work has gone into developing the XUL specification. Using XUL guarantees that most of the GUI changes will remain constant, not a new GUI specification that is a constantly changing API that is always trying to implement the most basic features.

If you're unfamiliar with XUL and its connection to the Mozilla platform, here are some links that may help:

  • XULPlanet.com (http://www.xulplanet.com/)
  • XUL Project Home Page (http://www.mozilla.org/projects/xul/)
  • Mozilla DevMo: XUL (http://developer.mozilla.org/en/docs/XUL)
  • XUL Wiki (http://wiki.mozilla.org/XUL:Home_Page)
[edit]

License

XUL Parser is distributed under a MPL/GPL/LGPL combo-license. Choose which one you want to distribute it under and off you go!

[edit]

Architecture

XulParser uses Java’s SAX parser to provide quick XML interpreting performance and native support for DTD files, a key localization feature of XUL Parser.

[edit]

Usage

Using XulParser is easy. Just create a XulFrame object and take in the file name of your XUL file to the constructor. XulFrame extends the JFrame class, so you can run setVisible(true) to show your GUI form and display your XUL GUI window! Obviously you need a way to get your GUI elements in order to manipulate them. For all the components that you need access to (like a JTextField element), make a id attribute for them in your XUL tag. Then use XulFrameObject.getElementById("idName") to retrieve that item. getElementById returns a JComponent corresponding to the ID you set in your XUL file. Once you know the element, you can then safely cast it to whatever component the XUL tag is.

Usage:

XulFrame frame = new XulFrame("C:/test.xul");
frame.show();
Button okBtn = (Button)frame.getElementById("okButton");

But XUL is not perfect, especially for Java developers. In order to make XUL more appropriate for Java, we added a namespace called JXUL which adds tags and attributes to make XUL easier for Java developers. Specifically this adds BorderLayout and a couple of other features not seen in XUL.

[edit]

Events

Events are done through JavaScript. This eliminates the need for truckloads of ActionListener or Action classes. It's just like HTML, put your JavaScript statement inside of the onclick attribute of a tag and it'll run when the element is clicked.

[edit]

But how do I talk with my Java code from JavaScript?

Rhino and XUL Parser provide a ton of ways from which you can access Java code from JavaScript. The most obvious way is through JavaScript import statements to import Java classes. To import a Java class to JavaScript, just insert this statement in your JS code:

importPackage(Packages.java.io.File);

var curFile = new File("myFile.txt");

Another way to integrate Java with JavaScript is by defining JavaScript references. Basically you point a JS variable to a Java instance.

java code:
  xulFrame.JavascriptEngine.setObjectReference(this, "document");
  xulFrame.JavascriptEngine.setObjectReference(this, "window");
  xulFrame.initializeJavascript();

js code:
  document.hide();
  var myButton = document.getElementById("myButton");
[edit]

Future

Currently, we plan on implementing full support for XUL in Java that will be interchangeable between Mozilla and Java XUL code.

We also need to add support for Eclipse SWT and possibly other Java GUI frameworks.

[edit]

Found a bug?

If you have problems using our GUI platform, please file a bug (http://mozcreator.mozdev.org/bugs.html) under the XULParser component.

Project Contact: R.J. Keller (mailto:rjkeller@kellertechnologies.com)

Retrieved from "http://www.kellertechnologies.com/projects/XUL_Parser_Project.htm"

Navigation

  • OPEN SOURCE
  • SUPPORT
  • ABOUT

Copyright © 2005-2006 Keller Technologies Inc.
All Rights Reserved
Contact Information | Privacy Policy

webmaster