Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

jTextfield problems  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do u set your jTextField so that it does not keep accepting input e.g for a name JTextField.how ca u also make it accept tex only and reject numerals
 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite sure what you meant with your first question,
but to make it read-only, use .isEditable(false) on your JTextField.

If you wanted to fix the size of the field, look at the constructors in the API, just add a number to the end, eg JTextField("",10);
I think thats how it works

I'm not sure about getting it to just accept letters,
Perhaps if you have a submit button, you could get this to allow/disallow certain input in the JTextField.
[ May 12, 2006: Message edited by: colin shuker ]
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either of the following can help:

JFormattedTextField

DocumentFilter
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added a KeyListener to my JTextField and told the key listener to not accept anything that's a number. If they type a number, it beeps and deletes the number.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Alice B Palmer:
I have added a KeyListener to my JTextField and told the key listener to not accept anything that's a number. If they type a number, it beeps and deletes the number.


Does this work if you copy or cut some text (^C or ^X) and then paste (^V) it into your text field?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!