setVisible should be faster than add/remove, but I don't think that is the entire story.
Invoking setVisible() means you have the Widget constructed and attached to the DOM. If you have only a few components in your application and can afford (memory wise) to create all widgets, then setVisible will work nice. On the other hand, if you are building a complex application with a huge number of widgets, it may not be possible to instantiate every Widget. In such cases, you would have to invoke the add/remove methods. I entirely agree with rjcarr - the speed gain isn't going to be great unless you have a very DOM intensive widget. --Sri 2009/10/4 rjcarr <[email protected]> > > I wouldn't imagine the speed would make much of a difference since DOM > manipulation is so fast in general. > > If you had to pick a faster solution, I'd say changing the visibility > would be faster, but you'd need to do some profiling to verify. > > On Oct 3, 12:58 pm, David Pinn <[email protected]> wrote: > > I want to confirm my understanding of the fastest way to reveal and > > hide widgets. For example, as the user navigates around my > > application, different widgets should appear in the 'contents' part of > > the screen. > > > > Am I correct in assuming that calling: > > > > myWidget.setVisible(true); > > myOtherWidget.setVisible(false); > > > > will be faster than calling: > > > > contentsPanel.remove(someOtherWidget); > > contentsPanel.add(myWidget); > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
