Implement a delay in Java
<p>Hi I have the following code:</p>

<pre><code>okBtn.addEventListener(Events.ON_CLICK, new EventListener()
{
            @Override
            public void onEvent(final Event arg0) throws Exception
            {
                //when the user clicks on ok, we take the current 
                //string from fckeditor...
                String currentValue = fckEditor.getValue();
                // set the string to preview to the current value 
                html.setContent(currentValue);

            }
 });
</code></pre>

<p>The problem I am facing is that there is a delay in this fckEditor.getValue() (the fckEditor is similar to a textArea) call because the ok action is faster than what fckEditor.getValue() takes to retrieve the data and in consequence sometimes when I modified the text in fckEditor really fast and hit the okBtn the changes are not reflected.</p>

<p>I came up with this solution, </p>

<pre><code>    okBtn.addEventListener(Events.ON_CLICK, new EventListener()
    {
        @Override
        public void onEvent(final Event arg0) throws Exception
        {

            String currentValue;

            synchronized (fckEditor)
            {
                currentValue = fckEditor.getValue();
                fckEditor.wait(100);
            }

            html.setContent(currentValue);

        }

    });
</code></pre>

<p>However, I am not fully convinced this will be the best solution because I am hard coding the delay <code>.wait(100);</code> and problably delays might differ in different computers. So eventually other environments might require more or less delay.</p>

<p>How can make the execution wait until the <code>fckEditor.getValue();</code> call has been completely finished? and so <code>currentValue</code> can hold the right String and be saved properly?</p>

<p>Thank you</p>
