jTextField

Hi,I have a problem that when six characters are typed in a jTextField, i want to delete typed text in it.Simply, my problem is to delete text typed in jTextField. How can i do this?
[203 byte] By [FuRK@Na] at [2007-11-27 9:15:23]
# 1
Add a key listener to the text field and on the key typed event check the length of the current text by using getText().length() and if it's 6 characters or greater then just set the text back to blank using setText("")
c0demonk3ya at 2007-7-12 22:04:25 > top of Java-index,Desktop,Core GUI APIs...
# 2

Well, I don't understand the question. Lets say you have "123456" displayed in a text field and you type the character "7". What happens:

a) all the text is removed and only a "7" is displayed

b) the "1" is removed so now you have "234567"

c) the "7" is ignored

d) as soon as you type "6" all the characters are removed

camickra at 2007-7-12 22:04:25 > top of Java-index,Desktop,Core GUI APIs...
# 3
I tried to use setText("") method and i don't remember the error but it doesn't compile the file. I mean setText("") does not work.null
FuRK@Na at 2007-7-12 22:04:25 > top of Java-index,Desktop,Core GUI APIs...
# 4
What i want to mean is exactly answer d.:)
FuRK@Na at 2007-7-12 22:04:25 > top of Java-index,Desktop,Core GUI APIs...
# 5
Well setText() is a standard method so I would suggest posting a SSCE so we can see the problem if you want further help... the error message you can't remember may just be useful too...
c0demonk3ya at 2007-7-12 22:04:25 > top of Java-index,Desktop,Core GUI APIs...
# 6

> What i want to mean is exactly answer d.:)

Then you should be using a DocumentFilter or DocumentListener (depending on your exact requirements), not a KeyListener.

setText("") should work.

As suggested above, If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",

see http://homepage1.nifty.com/algafield/sscce.html,

that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the "Code Formatting Tags",

see http://forum.java.sun.com/help.jspa?sec=formatting,

so the posted code retains its original formatting.

camickra at 2007-7-12 22:04:25 > top of Java-index,Desktop,Core GUI APIs...
# 7
Thanks for help about jTextField, i'll try to do it, and also thanks for SSCCE
FuRK@Na at 2007-7-12 22:04:25 > top of Java-index,Desktop,Core GUI APIs...