|
![]() |
Chronicle of the Xul Revolution |
The XAML4J Swing demo shows how you can use XAML4J to build the UI for a Swing Java program using XML.
Why would you want to do this? If you have ever written a large
Swing application, you will probably agree that coding a GUI in Java
can be a tedious task. XAML4J allows you to define the View (in an MVC
approach) in XML and bind it to a Model and Controller written in
Java. Or you can define actions (Controller) directly in XAML4J by
using the <action>
tag.
XAML4J is also a great way for a designer to prototype a UI and avoid the learning curve of Java. In fact, a designer could develop a full-featured application using a rich set of functions and beans exposed via XAML4J tags.
To run the swing demo, go to directory xaml4j/swing and type "maven demo:swing" (View the demo script ). You should see a window open with some swing components. You can test the actions by selecting a menu item or pressing the button. The actions in this demo simply output a message to the console. A more practical action could be to invoke a bean, call a script that opens another window, etc.
If you look at the XAML4J code for this demo , you will see that building a UI is pretty simple. For example, a menu bar is simply:
<menuBar> <menu text="File"> <menuItem> <action name="New"> ... some action ... </action> </menuItem> </menu> ... more menus/menu items </menuBar>
As you can see, nested elements are automatically added to parent
components (unlike Java, where you have to call parent.add(child)
).
|
Please send comments on our web pages to our public xul-talk mailinglist or to a member of our web team. | Copyright © 2003, 2004, 2005 Open XUL Alliance |