GWT: can I put Delay in a few seconds after showing a popup

I have a small GWT application in which I display a popup with 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 I can put a trade in 5 seconds before hiding a popup

thanks

+7
source share
2 answers

Here is the code that Timer uses to create a delay of 5 seconds:

  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); 
+20
source

You can use com.google.gwt.user.client.Timer , which allows you to schedule a task in the future.

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

+5
source

All Articles