restricting text and forcing UPPERCASE in an applet
I have an applet where the users can enter anything into a text field. I would like to restrict user input to "Y" and "N" only. Also I would like them to be able to enter"y" and the text is converted into uppercase "Y". I'm using Sun One studio to develop in
Thanks for any help
You can use the toUpperCase function of strings to convert everything to uppercase. Just take their text and use the fnction, Eg:
String upperCase = theirText.toUpperCase();
Hope this helps!
if you are using JDK 1.4 you could try to see if JFormattedTextField will do what you wish.
Otherwise, perhaps implement a textListener to activate when the content of the text field changes and if the text entered is not y/Y or n/N you can set it back to empty string and as MasterOfSouls stated, you can use str.toUpperCase()
Laziness is a virtue.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center