Using a button to refresh a panel in GWT

I have a small web application project using GWT, where a button handles an event: populating a panel with widgets. Currently, clicking the button a second time will duplicate the panel, i want it so it clears the panel, and re adds the widgets.

So far I have:

final Button b = new Button("get schools near me");
    final HorizontalPanel panel = new HorizontalPanel();
    b.addClickHandler(new ClickHandler(){
        public void onClick(ClickEvent event) {
            Timer t = new Timer(){
                public void run() {
                    //how do you clear the panel here first? before you
                    // do a bunch of things along the lines of:
            t.schedule(1400); // wait 1.4 seconds for callback

I get that anything you pass to the run function has to be as a final declaration, so how do I get around this?


You can use the clear method:


Leave a Reply

Your email address will not be published. Required fields are marked *