Tips and Tricks

This section contains general Tips and Tricks when working with gui4j.

KeyMaps


Inline keyMaps directly into your GUI description with any special settings (i.e. keyboard shortcuts for button execution on specific keys), but place generic keyMaps like setting TAB to ENTER in a table to a common included XML file (e.g. templates/keyMaps.xml).
This will increase reusability of general definitions.
 

Styles


Instead of declaring attributes in every element of a specific form, exclude these common attributes and place them in a extra file (i.e. config/styles.xml). Include this file by use of a Include.
 

Layout


It is useful to work with low nesting depths. When doing complex layouts, the XML-structure might become difficult to read. So only declare real GUI components only if they require one or two lines. Otherwise use the id attribute as seen on all layouting placing elements (e.g. borderLayout’s placeBl) or the Ref element to declare a reference to another GUI component.
 

GUI templates


When the same component structure or layout is used several times in an application, it can be extracted to a separate file and be defined only once.
The following example shows a simple, but useful layout: