• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic