user1226162
user1226162

Reputation: 2032

GWT:can i put Delay for few seconds after showing a popup

I have small GWT application , in which i am showing a popup on success

           if(success){
               DescoratedPopupPanel popup = new DecoratedPopupPanel();
               popup.show();
               //Now here i want to wait for like 5 secs and then 
               popup.hide();
             }

Any idea how can i put a dealay of 5 secs before hiding the popup

Thanks

Upvotes: 9

Views: 13814

Answers (2)

ftr
ftr

Reputation: 2145

You could use a com.google.gwt.user.client.Timer which lets you schedule a task in the future.

As Thomas Broyer mentioned in the comments, you could also use com.google.gwt.core.client.Scheduler#scheduleFixedDelay() with a RepeatingCommand that always returns false to indicate that it should only be executed once.

Upvotes: 5

Ganesh Kumar
Ganesh Kumar

Reputation: 3240

Here is the code that uses Timer to produce 5 secs delay:

        final DecoratedPopupPanel popup = new DecoratedPopupPanel();
        popup.show();
        // Now here i want to wait for like 5 secs and then
        Timer timer = new Timer()
        {
            @Override
            public void run()
            {
                popup.hide();
            }
        };

        timer.schedule(5000);

Upvotes: 23

Related Questions