This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes limiting input from a textfield??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "limiting input from a textfield???" Watch "limiting input from a textfield???" New topic

limiting input from a textfield???

raymond yadao
Ranch Hand

Joined: Jan 29, 2001
Posts: 88
How would i do to limit the input for a textfield?
For example, i used the constructor:
TextField tf = new TextField(10);
still it doesn't limit the input(let say 10 characters)??
Michael Matola
Ranch Hand

Joined: Mar 25, 2001
Posts: 1740
This may not be exactly what you want, but if you happen to use Swing instead of AWT, there's javax.swing.InputVerifier that can handle this sort of validation.
I agree. Here's the link:
subject: limiting input from a textfield???
Similar Threads
JTextField(int col)
want to set limitation column at textfield/textarea(Urgent)
Need to limit the text
Input Textfield Background Color When the Cursor Is There
JTextField set size limit.