Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT: How to put event in queue (equivalent to Swing invokeLater())?

Tags:

java

events

gwt

Having the following szenario: blurring a textBox (input) writes text to my status-Box (in certain conditions), and clicking a button also writes text to the status-Box.

Now when clicking the button it will blur my textBox if it is focused and that will cause the status-Box to flicker as first the blurHandler will write its result and then the clickHandler. As i want the result of the clickHandler to appear my idea is to let the blurHandler place an event at the end of the queue which checks whether a clickHandler has written a result before.

In Swing I would try SwingUtilities.invokeLater(Runnable). The equivalent in GWT is said to be the Scheduler but those deferred or finally commands seems always to run after the current event and before the next. So far i use Scheduler.scheduleFixedDelay with 100ms delay and hope it comes after the clickHanlder in each browser. See similar problem with answer.

I think there must be a better solution for this. How to really add an event to the end of the queue or is it impossible due to limitations of HTML?

like image 394
Zak_Rhol Avatar asked Mar 23 '12 07:03

Zak_Rhol


1 Answers

Try:

Scheduler.get().scheduleDeferred(new Command() {

                        @Override

                        public void execute() {
                                .......
                        }
                });

See

Class Scheduler

like image 71
Andrzej Jozwik Avatar answered Sep 21 '22 10:09

Andrzej Jozwik