Displaying only one panel at once

146 views Asked by At

I'd like to have the effect of one of two panels visible at given time in the same place on the screen. Perhaps I could use the DeckPanel but then in the designer I wouldn't be able to edit the hidden one. Maybe you could recommend a technique?

I've found a solution which works but is not pretty IMHO. Ie. in the code I insert the panel which I want to be visible and remove the panel which I don't want to be visible (from the containing panel).

3

There are 3 answers

0
enrybo On

Just put both panel within another panel and then set their visibility.

Panel mainPanel = new Panel();
Panel subPanel1 = new Panel();
Panel subPanel2 = new Panel();

mainPanel.add(subPanel1);
mainPanel.add(subPanel2);

subPanel1.setVisible(true);
subPanel2.setVisible(false);

And then when you want to see panel 2 you just do this:

subPanel1.setVisible(false);
subPanel2.setVisible(true);
0
Igor Klimer On

If you want to do this the "right" way, I'd suggest looking into the MVP pattern that GWT team in is suggesting for maintaining large-ish GWT application.

Take a look at possible implementations: mvp4g or gwt-platform. They will take care for you of switching views, as well as maintaining history (the back/forward buttons will work as they should) and many more.

0
Suresh Atta On

You can go for Tablayoutpanel Need not to maintain your own code .