Menubar

The creating of menubars is an excellent example of where in Java the long list of statements becomes an unreadable
and hard to understand mess. The best example is the url where Sun explains how to use Menus.

This demostration menubar looks like this:

The code that generates this menu is not immidiatly clear in itself. Extra
measures are needed as you can see in the next code sniplet.

To accomplisch the same as shown in the above code sniplet you could
write in Java-Swul the following:

Events

To demonstrate how the events that the userinterface components generate can be handled in Java-Swul we take the
following interface.

Event handlers are connected to the window, the file menu, an item in the file menu, to the button and to the slider. That an event from of user interface component shoud be listened to and how it should be handled is declared as a property of a Swul component. The right hand side of such a property is an block of Java statements. The following piece of code shows how the previous user interface is created and how the event handlers are declared.

The event blocks are collected into a new innerclass that is created in the class where the events properties were declared. The components are connected to the methods in this new innerclass by the creation and connection of EventHandler objects. In this way only a single object is created to hold the reactions to events and the EventHandler uses proxies to create only a single object per eventtype. This reduces the footprint of the Java program when an eventtype accurs more then once compared to the classic method of using (annoymous-)innerclasses per event.

Some of the generated code to create and connect the components is shown here:

Creating a GridBagLayout with ease

A GridBagLayout is in practice a complex layout. If you would create
a layout of your components with this layoutmanager this often means
calculation of cell locations and width/height values.

Take for instance the following interface:

Components can span multiple cells. In the example they span horizontal,
vertical, both or neither. Java-Swul can calculate the values of the width,
height, x-position and y-position for you. The input for this calculation
is a more understandable way of writing down how the grid should be filled.

The above screen is the result of the following java / java-swul code.
Placement of components is closer to the concept that a gridlayout offers,
making it easier to create and alter a gridlayout.

Widget-o-rama

The next screenshot is from a file called xmpl/Test16.javaswul in the Java-Swul package.

The Java-Swul source used to create this crowded interface contains the next code-example.
The surrounding Java code is left out to save some space. The complete Java code is further down on
this page.

As you can see it is quite verbose. Writing things down in this structured way causes lots of lines with just an } and spaces.
Java-Swul has some sugur to it. The line scrollpane of panel of grid layout { row = { ... } } is short for: