This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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!
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 ]