RootPanel can only contain one widget.  So create some panel widget -
verticalpanel, flowpanel, etc, add it to RootPanel, and add your
widgets to that.  Then you can do setVisible to hide/unhide.

On Apr 21, 10:57 pm, GWTNewbie <[email protected]> wrote:
> Hi:
> I am new to GWT. I have 2 widgets Widget1 and Widget2. Both the
> Widgets have 1 Label and 1 Button each. The Widgets are created using
> UiBinder. When I launch the application I want to display Widget1.
> When I click on the button of Widget 1 I would like to hide the widget
> and then display Widget 2 and vice versa. Any suggestions as to how
> this can be achieved ?
>
> Widget 1:
> public class Widget1 extends Composite {
>
>         interface Widget1UiBinder extends UiBinder<Widget, Widget1> {
>         }
>
>         private static Widget1UiBinder uiBinder =
> GWT.create(Widget1UiBinder.class);
>
>         @UiField
>         Button click1;
>         @UiField
>         Anchor signOutLink;
>
>         public Widget1() {
>                 initWidget(uiBinder.createAndBindUi(this));
>         }
>
>         @UiHandler("click1")
>         void onClick(ClickEvent e) {
>                 this.setVisible(false);
>         }
>
>         @UiHandler("signOutLink")
>         void onClickSignOutLink(ClickEvent e)
>         {
>                 this.setVisible(false);
>         }
>
> }
>
> Widget 2:
>
> public class Widget2 extends Composite {
>
>         interface Widget2UiBinder extends UiBinder<Widget, Widget2> {
>         }
>
>         private static Widget2UiBinder uiBinder =
> GWT.create(Widget2UiBinder.class);
>         @UiField
>         Button click2;
>
>         public Widget2() {
>                 initWidget(uiBinder.createAndBindUi(this));
>         }
>         @UiHandler("click2")
>         void onClick(ClickEvent e) {
>                 this.setVisible(false);
>         }
>
> }
>
> Entry Point:
> public class SwitcherApp implements EntryPoint {
>
>         public void onModuleLoad() {
>                 RootPanel.get().add(new Widget1());
>                 RootPanel.get().add(new Widget2());
>         }
>
> }
>
> --
> 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 
> athttp://groups.google.com/group/google-web-toolkit?hl=en.

-- 
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.

Reply via email to