Best practice for rebuild parts of the UI.

After some data changes my code rebuilds a part of the complex UI. The code works fine.

But what is the best practice for rebuilding the UI?

Should I use the
removeAllComponents()
methods, or should I re-create all UI elements. For first method the code is a little ugly - if statments for the desicion inital build or rebuild. The code for complete (re)bulding is more simple - but I am not sure what happens with the old, non used UI elements after UI rebuild. Victims of the GC or unused objects in the memory?

Peter

Unused components are garbage collected according to normal Java rules; the only thing that might influence your decision is the (slight) performance impact of re-creating the component objects.

As far as best practices goes, for this particular case there really isn’t one; it depends on your navigation pattern.