Monday, July 28, 2014

Re: onResize not called in custom widget

+1 Jens  -> Remember to use only Layout Panels  + have a look to http://www.gwtproject.org/doc/latest/DevGuideUiPanels.html#Design

On Sunday, July 27, 2014 6:59:56 PM UTC+2, Jens wrote:
Hi,

I want to create a custom widget. It's based on ResizeComposite and it will contain some special graphical stuff in a HeaderPanel.
I will have to rearrange the graphical stuff when the custom widget is resized. I'm overriding the onResize()-Method of ResizeComposite for this purpose,
but it seems not to be called when resizing occurs.

This is the (simplified) code of my custom widget:

public class DendrogramWidget extends ResizeComposite {

   
public static final String CLASSNAME = "dendrogram";

   
private HeaderPanel mainPanel;
   
private Button header = new Button("graph-header");
   
private Button footer = new Button("graph-footer");
   
private Label label = new Label("later on, here will come the graphical stuff");

   
public DendrogramWidget() {

       
this.mainPanel = new HeaderPanel();
       
this.initWidget(this.mainPanel);
       
this.setStyleName(CLASSNAME);
       
this.mainPanel.setSize("100%", "100%");

       
this.mainPanel.add(header);
       
this.mainPanel.add(label);
       
this.mainPanel.add(footer);

       
this.mainPanel.setHeaderWidget(header);
       
this.mainPanel.setContentWidget(label);
       
this.mainPanel.setFooterWidget(footer);

       
this.header.addClickHandler(new ClickHandler() {

           
@Override
           
public void onClick(ClickEvent event) {
               
String name = ((Button)event.getSource()).getText();
                label
.setText("clicked on "+name);
           
}

       
});

       
this.footer.addClickHandler(new ClickHandler() {

           
@Override
           
public void onClick(ClickEvent event) {
               
String name = ((Button)event.getSource()).getText();
                label
.setText("clicked on "+name);
           
}

       
});

   
}

   
@Override
   
public void onResize() {
       
super.onResize();
        label
.setText("onResize() called ["+DendrogramWidget.this.getOffsetWidth()+","+DendrogramWidget.this.getOffsetHeight()+"]");
   
}

}

As you can see, it's pretty simple (yet). I'm expecting the text of the label being changed when resizing the widget, but nothing happens.
I'm new to GWT so maybe I'm missing something important.

Can anyone give me an advice what's going wrong here?

Thanks in advance,

Jens



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment