Thanks for your help.

I'll try the Caption Panel.

On Jan 29, 1:43 am, Thomas Broyer <t.bro...@gmail.com> wrote:
> On Jan 29, 2:20 am, Pion <onlee2...@gmail.com> wrote:
>
> > I have the following code snippets:
>
> >                 VerticalPanel verticalPanel = new VerticalPanel();
>
> >                 Element fieldset = DOM.createFieldSet();
>
> >                 DOM.appendChild(verticalPanel.getElement(), fieldset);
>
> A VerticalPanel's element is a <table>, you really shouldn't add a
> <fieldset> as a child of a <table>.
>
>
>
>
>
> >                 Label label = new Label("Messages");
> >                 label.addClickHandler(new ClickHandler() {
> >                         public void onClick(ClickEvent event) {
> >                                     debug("Messages handler");
> >                                 }
> >                         }
> >                 );
>
> > Based on the above, I have the following 2 options:
>
> >                 // Option 1: When I click "Messages", it calls 
> > debug("Messages
> > handler").
> >                 // It works as expected.
> >                 verticalPanel.add(label);
>
> >                 // Option 2: When I click "Messages", it did not call debug
> > ("Messages handler")
> >                 // It does not work as expected. I expected that it should 
> > call debug
> > ("Messages handler")
> >                 DOM.appendChild(fieldset, label.getElement());
>
> > I am using GWT 2.0.
>
> > What did I do wrong on option 2? I want the label inside the fieldset.
>
> You have to first understand how events work in 
> GWT:http://code.google.com/webtoolkit/doc/latest/DevGuideUiCustomWidgets....http://code.google.com/p/google-web-toolkit/wiki/DomEventsAndMemoryLeakshttp://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/g...()
> But actually, the best documentation is the code itself (have a look
> at Widget's onAttach/onDetach and Panel's add/remove methods)
>
> You could also take advantage of event bubbling, which would make your
> code much 
> simpler:http://code.google.com/webtoolkit/doc/latest/FAQ_UI.html#How_can_I_ef...
>
> Oh, and why not use a CaptionPanel for you 
> <fieldset>?http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/g...
> Extending CaptionPanel and using event bubbling to detect clicks on
> the <legend> (assuming you actually want the label to be the
> fieldset's caption) would probably be easier than re-creating a
> CaptionPanel-like widget to handle those clicks through a child Label
> widget.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to