• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Automatic Tab

 
Rocky Summers
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • 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
 
saager mhatre
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • 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!
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic