How to set Jtextfield Maxlength?..

I have coded my password field's length like this. But i wanna set the password field to 8 characters, user can't write anything bigger than 8 characters. how can i do that ? is there anything something like "textfield maxlength" in jtextfield proporties ??? Waiting for you help...

I have coded my password field's length like this. But i wanna set the password field to 8 characters, user can't write anything bigger than 8 characters. how can i do that ? is there anything something like "textfield maxlength" in jtextfield proporties ??? Waiting for you help...

A Document object manages the text entered in the JTextField; add a DocumentListener to that object and make it check for the length of the text; if it is too long, remove the offending char from the Document.

@OP: Good luck finding it. And thanks for the question: if I had known about DocumentFilter before, I had forgotten about it.

@World: Is this a modern tendency, to introduce everything with "hafta" or "juswanna"?

The first denies the essential contingency of everything and ignores the fact that whatever we do involves choice and decision. The second pretends that our actions do not have consequence and entail nothing.

It is a cheap rhetorical reflex whereby the speaker aims to obtain agreement either by claiming that something is inevitable (the haftas) or a small matter that it would be churlish to reject (the juswannas). With uncritical repetition the rhetoric becomes ingrained in both speaker and listener as an idle and irresponsible philosophy.

Of course there is a much simpler way but we are complete bastards and do not what to share the secret with a schmuck like you. Therefore the much harder solution was suggested. So you can either bite the bullet and do it the hard way or study lots, become more proficient and experienced and then after ~10 years when you are a Java Guru somebody MIGHT tell you how to do it the easy way.

Of course there is a much simpler way but we are complete bastards and do not what to share the secret with a schmuck like you. Therefore the much harder solution was suggested. So you can either bite the bullet and do it the hard way or study lots, become more proficient and experienced and then after ~10 years when you are a Java Guru somebody MIGHT tell you how to do it the easy way.

And he has to do the secret handshake and the silly dance! I'll go and fetch the syrup and feathers.