Hi,
I'm making a few steps in java.awt and I found myself with this
problem.
When the user inserts a certain string in a TextArea, a KeyListener
does a few operations and clears the content of the TextArea (with
setText("")).
However, not all the content of the area is cleared. The last inserted
letter still appears in the empty TextArea.
I tried repainting the content of the area before clearing the content,
but it did not work.
I'm using jdk 1.5r6
Lionel - 02 Apr 2006 22:56 GMT
> Hi,
>
[quoted text clipped - 11 lines]
>
> I'm using jdk 1.5r6
I just happened to be using a KeyListener the other day and found
similar behaviour with another component. I'm guessing you are using the
KeyPressed method? What happens is that you get given access to the key
that was pressed, but the key doesn't get inserted into the text area
until after your method has completed, or possibly after the key is
released, so you will clear it and then it will put the key in. You
might want to try implementing the KeyReleased method instead.
Lionel.
falesca - 03 Apr 2006 18:41 GMT
Thanks a lot,
I really should have thought about it.
I'll check this solution as soon as I recreate my svn repository.
Matteo