Invalidation

Invalidation is the mechanism used by the components to limit the number of times the component redraws when multiple properties are changed. When a component is invalidated, it will redraw itself on the next frame. This enables developers to throw as many changes at once to the components, and only have the component update once. There are a few exceptions where the component needs to redraw immediately; however for most cases, invalidation is sufficient.

Figure 63: CLIK components automatically invalidate when certain properties are changed.

Usage and Best Practices

After any internal component change (usually caused by setter functions), UIComponent.invalidate() should be called, which ultimately calls UIComponent.draw()in the component. The invalidate() method generates the draw() call using a timer-based delay to avoid unnecessary updates. Developers using the existing components will likely not need to manage invalidation, but should at least be aware of it.

For cases where an immediate redraw is required, developers can use the UIComponent.validateNow() method.