Home
Blog
Downloads
Photos
Resumé
Stuff
Firefox
OpenOffice.org
Valid HTML 4.0 Transitional
Valid CSS

JAML



Description

The acronym "JAML" stands for "Java Application Markup Language" and, loosely speaking, refers to a language for describing Java interfaces in a XML-style document. However, the name also refers to the entire library that I wrote to enable robust parsing, validating and building of these interfaces in a way that is extremely easy to use and extend.

What does this mean? In layman's terms, JAML is a code library that allows the software developer to design the interface of their application (the way it looks to you as the user) in a language similar to HTML (the language used to create simple webpages). This makes it a lot easier and faster to create the program. It also means that there's a possibility that YOU, as the user, will be able to change the interface yourself simply by editing the application's JAML file. Imagine being able to rearrange the buttons and options on your favorite application to exactly the layout that works best for you. That is the flexibility that JAML provides.

For developers: if you're familiar with XAML, then you will catch on quickly; it's basically the same thing for Java. If not, perhaps the following example will make it clear:


<frame name="mainWindow" title="Main Window" width="300" height="180" close="exit" >
    <borderlayout />
    <panel dock="center" >
        <boxlayout axis="y" />
        <panel>
            <label name="uname" text="Name: " />
            <textbox cols="18">John Smith</textbox>
        </panel>
        <panel>
            <checkbox name="slashdot" text="Slashdot member" />
        </panel>
        <panel>
            <flowlayout align="left" hgap="20" />
            <label text="Notes: " />
            <textarea name="notes" width="200" height="40" />
        </panel>
    </panel>
    <panel dock="bottom">
        <flowlayout align="right" />
        <panel>
            <gridlayout cols="2" hgap="5"/>
            <button name="default" text="OK" />
            <button name="cancel" text="Cancel" />
        </panel>
    </panel>
</frame>

The above code (written in Simple JAML) describes an interface. The following Java class uses the JAML library to build a real application using that interface, assuming that all of the above is in the file "sample.jaml".


public class SampleApp {
    private JFrame mainWindow;
    public static void Main(String[] args) {
        try {

            // parse the interface file
            JAMLEngine.addFile("sample.jaml");

            // get a reference to the main window object
            mainWindow = (JFrame)JAMLEngine.get("mainWindow");

            // show the main window
            mainWindow.setVisible(true);

        } catch (IOException iex) {
            JOptionPane.showMessageDialog(null, 
                    "Error accessing \"sample.jaml\": " + iex.getMessage());
        } catch (JAMLException jex) {
            JOptionPane.showMessageDialog(null, 
                    "Error parsing or building interface: " + iex.getMessage());
        }
    }
}

That's all the code it takes! Technically, you could get by with even less code by using a slightly different method (there are many ways to use the JAML library), but it's recommended that you just use the method illustrated above. The result is the following interface:


screenshot

At this point, the basic framework of the JAML library is very much complete. Mechanisms are in place for nearly all expected features, although not all have implementations. Currently, the JAML library will parse, validate and build Java interfaces from "Simple JAML," which is a language I wrote (or rather: I am making up as I go...) for writing interfaces in XML. The interface code above is an example of an interface written in Simple JAML.

Eventually I plan to add implementations for two other languages: the "real" Swing JAML, which will be based on Java Swing objects, and XAML, Microsoft's application markup language. This would provide developers a wide range of languages to use in writing their application GUI, and of course they can always modify or extend an existing language, or simply use actual Java code to set properties and use Swing features that the languages do not include.

View Readme/Changelog


Features

Fully implemented:

  • Basic JAML library structure, including data structures, exceptions, a utility class, base interpreter classes and a JAMLEngine object to tie everything together
  • Parses simple JAML and/or XML documents into a JAMLObject structure
  • JAMLPad application allows developers to preview interfaces as work
  • Allows developers to customize any part of the process, and simplifies adding a new interpreter language

Partially implemented:

  • Simple JAML interpreter

TODO:

  • Swing JAML interpreter
  • XAML interpreter

Download

NOTE: THIS IS CURRENTLY A PRERELEASE (ALPHA) VERSION. EXPECT INCOMPLETE, INCORRECT AND/OR MISSING FEATURES AND DOCUMENTATION, AS WELL AS LOTS OF SOFTWARE DEFECTS ("BUGS"). I AM NOT RESPONSIBLE FOR ANY DAMAGE, LOSS OR MENTAL INSANITY RESULTING FROM THE USE OR MISUSE OF THIS SOFTWARE.

JAML itself is distributable as a JAR file that includes the JAMLPad application. I will include this JAR file as an optional download, but what you probably really want is the .zip (Windows) or .tar.gz (*nix) file, which include the entire developer directory, including the compiled JAR file, sources and all documentation.


NOTE: This project requires that a Java Runtime Environment be installed on your system. If nothing happens when you try to launch the program, try installing the Java Runtime Environment before you send in an error report:

Java 2 1.5.0 SE Downloads


You will want to click "DOWNLOAD" in the "Windows Offline Installation" row under the "JRE" column in the second table.




Last modified: 06/09/06
Copyright (c) 2004 Michael Lam