Last month, a reader commented that BML didn't work as well as an IDE, or integrated development environment, for creating user interfaces, and I agree. But the power of and interest in BML derives from its ability to create structures of arbitrary classes -- not just user interfaces or JavaBeans -- to build an application. More importantly, BML can define an application declaratively, usually without procedural code. This makes it much easier for (potential) builder tools to compose functionality into applications, much in the same way a dialog editor composes GUI elements into a user interface. In fact, since BML defines applications structurally rather than procedurally, it can be used to automatically generate interactive interfaces for arbitrary datastructures.
IBM's Bean Markup Language provides just such a software chassis for Java object instances, particularly instances of JavaBean components. As I demonstrated in August (see Part 1 of this two-part series in Resources below), you can use BML to create configured instances of JavaBeans.
This month, I'll show you how to create instances of several objects in BML and then use BML to wire these objects together. I'll also show you how to execute any method of an object from BML, extend BML to handle conversions between data types, and explore binding Java objects created in BML to a scripting language (in this case, JavaScript). Since I assume you've read the first article, let's dive right into this month's sample code.
I'm going to extend last month's ColorFadeBean by transforming it into the interactive ColorFadeEditor.bml (click the link to see the file). I've added an AWT text field to the original ColorFadeBean, which sets the text in the ColorFadeBean, and three ColorChooser objects, which set the text color and the start and end colors for the color gradient. A picture of the ColorFadeEditor appears in Figure 1.

Figure 1. ColorFadeEditor defined entirely in BML
This application is actually a single-nested hierarchy of GUI elements, as it must be, since an XML document may have only
one top-level element. You'll notice that the BML file contains no Java code. That's because BML is a language used for wiring
JavaBeans together, not for creating new JavaBeans (although defining JavaBeans in BML will be a feature of an upcoming BML
release). The color gradient in the ColorFadeBean, for example, is created by the bytecodes in ColorFadeBean.class, which can be considered an off-the-shelf JavaBean. BML sets the bean's exposed properties and so on, but it can't add new
properties or behavior.
ColorFadeBean used in the example in this article