• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Automatic Tab

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello ranchers!
just wondering.... how do i do an automatic tab? for example: i have 3 text fields.. on the first text field, if i enter 3 characters, it automatically tabs to the second textfield.. and if in the 2nd txtfield, if i enter 3 characters, it automatically tabs to the third txtfield.. and on the third txtfield, if i enter more than 7 characters, it won't allow it to add more.. is there any way to do this?
please let me know... thank you!
~ rockster
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This shouldn't be too hard. You'll have to set up DocumentListeners for the Document models of the three JTextComponents in question and monitor the events for changes in length of entered text. Once a component reaches its threshold, simply call the suitable requestFocus() method on the component you want to move to!
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to limit the content of the textfields to a number of chars, calling methods(*) on the Document object from within a DocumentListener might deadlock. The approach given in the Java Tutorial is implementing a document filter
(*) Those that modify the text
[ January 31, 2004: Message edited by: Jose Botella ]
 
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic