Styles

Gui4j supports the style concept to simplify the description of graphical user interfaces with the same look and feel. For instance, all editable number fields, should be displayed with white background, blue text color and right alignment:

<edit value=”getValue” setValue=”setValue(?value)” alignment=”right”
  background=”:Color.WHITE” foreground=”:Color.BLUE”/>

For this look and feel we need three attribute values and for all edit components we have to repeat this information. This is redundant information and much effort to change when the text color should now be black, for instance.

The style concept allows to group attribute values in a style and gui4j components simply refer to that style name:

<Style name=”editNumber”>
  <Style_edit alignment=”right” background=”:Color.WHITE” foreground=”:Color.BLUE”/>
</Style>

<edit value=”getValue” setValue=”setValue(?value)” style=”editNumber”/>

The outer element Style introduces a new style name. For each supported guij4 component there is an additional tag Style_tagName to define the corresponding style attributes. These tags are used inside the Style element. In other elements a style is referenced using the style Attribut. The style reference only adds not already defined attributes. For instance, if the background color is defined in the style and in the element referencing the style, then the attribute value of the element referencing the style is used, since this has priorty.