zaccret
05-27-2008, 09:12 AM
I think this is more Javascript than Java discussion.
I have a set of containers, containing other components. No more than one container is displayed in a Viewport at the same time. I often switch between these containers. You can compare that with Eclipse perspectives.
So in the Viewport, when I replace a component (that I will probably re-use later) by another, what is the best practice regarding performance and memory usage :
- keep the component in a variable, remove it from the Viewport and add the new one
- keep the component (or its id) in a variable, hide it, and add the new one to the Viewport (for that case, using a CardLayout is equivalent, I think)
I have a set of containers, containing other components. No more than one container is displayed in a Viewport at the same time. I often switch between these containers. You can compare that with Eclipse perspectives.
So in the Viewport, when I replace a component (that I will probably re-use later) by another, what is the best practice regarding performance and memory usage :
- keep the component in a variable, remove it from the Viewport and add the new one
- keep the component (or its id) in a variable, hide it, and add the new one to the Viewport (for that case, using a CardLayout is equivalent, I think)