Wednesday, February 29, 2012

Re: the output of DialogBox is very strange

I don't think setSize is really supported for the content area of the
DialogBox since setSize is inherited from UIObject. I believe the
size you're setting is the actual dialog box's outer dimensions (ie.
the DecoratorPanel's table) and not your content's dimensions.

What you'll really want to do is have your dialog box's main content
widget sized how you want it and let dialog box size itself based on
that - as RKP Pisters suggested.

On Feb 28, 8:21 pm, tong123123 <tong123...@gmail.com> wrote:
> thanks for the reply.
> I found the problem seems related to Dialogbox.setsize(), if call this
> method, the dialogBox will be very strange, just try the following to
> simulate:
>
> public class GWTTest1 implements EntryPoint, ClickHandler {
>
>           private static class MyDialog extends DialogBox {
>
>             public MyDialog() {
>               // Set the dialog box's caption.
>               setText("My First Dialog");
>
>               // Enable animation.
>               setAnimationEnabled(true);
>
>               // Enable glass background.
>               setGlassEnabled(true);
>
>               // DialogBox is a SimplePanel, so you have to set its widget
> property to
>               // whatever you want its contents to be.
>               ScrollPanel scrollPanel1 = new ScrollPanel();
>               //scrollPanel1.setSize("1800px", "500px");
>               setWidget(scrollPanel1);
>               Button ok = new Button("OK");
>
>               ok.addClickHandler(new ClickHandler() {
>                 @Override
>                 public void onClick(ClickEvent event) {
>                   MyDialog.this.hide();
>                 }
>               });
>               scrollPanel1.add(ok);
>
>             }
>           }
>
>           public void onModuleLoad() {
>             Button b = new Button("Click me");
>             b.addClickHandler(this);
>
>             RootPanel.get().add(b);
>           }
>
>           public void onClick(ClickEvent event) {
>             // Instantiate the dialog box and show it.
>             MyDialog myDialog1 = new MyDialog();
>             // if myDialog1.setSize(), will throw very strange result!!
>             myDialog1.setSize("1800px", "500px");
>             myDialog1.show();
>           }
>         }
>
> if comment out the statement "myDialog1.setSize("1800px", "500px");"
> and uncomment the statement //scrollPanel1.setSize("1800px", "500px");
> everything is ok.
> so I think the DialogBox.setSize() has some problem.

--
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-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment