Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2006

Tip: Looking for answers? Try searching our database.

Awt: cleaning the content of a TextArea

Thread view: 
falesca - 02 Apr 2006 22:15 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.