Widget Library

The widget library provides very common widgets with basic implementations. These simple widgets may not provide every desired feature, but they can easily be forked since their implementation is very simple.

The widget library does not provide any example. However, the widget demo provides examples for these widgets.

Source

To use the widgets provided by the widget library, add the following line to a module description file:

<dependency org="ej.library.ui" name="widget" rev="4.1.0"/>

To fork one of the provided widgets, duplicate the associated Java class from the widget library JAR into the source code of your application. It is recommended to move the duplicated class to an other package and to rename the class in order to avoid confusion between your forked class and the original class.

Provided Widgets

Widgets:

  • Label: displays a text.
  • ImageWidget: displays an image which is loaded from a resource.
  • Button: displays a text and reacts to click events.
  • ImageButton: displays an image which is loaded from a resource and reacts to click events.

Containers:

  • List: lays out any number of children horizontally or vertically.
  • Flow: lays out any number of children horizontally or vertically, using multiple rows if necessary.
  • Grid: lays out any number of children in a grid.
  • Dock: lays out any number of children by docking each child one by one on a side.
  • SimpleDock: lays out three children horizontally or vertically.
  • OverlapContainer: lays out any number of children by stacking them.
  • Canvas: lays out any number of children freely.

Debug Utilities

A few utilities useful for debugging are available in the package ej.widget.util.debug of the widget library.

Count the Number of Widgets or Containers

The methods HierarchyInspector.countNumberOfWidgets(Widget) and HierarchyInspector.countNumberOfContainers(Widget) respectively count the number of widgets and containers in a hierarchy.

It may be used to evaluate the complexity of a hierarchy of widgets.

Count the Maximum Depth of a Hierarchy

The method HierarchyInspector.countMaxDepth(Widget) counts the maximum depth of a hierarchy. In other words, the depth of the widget with the biggest number of parents recursively.

It may be used to evaluate the complexity of a hierarchy of widgets.