0

Hi, can anyone tell me how to make the text a user types into a JTextfield appear in uppercase regardless if caps is on or not?
Thanks
Glen..

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by GlenRogers
0

You need to implement the KeyListener interface(or alternatively extend KeyAdapter class) in this case and by using getKeyCode() event you can retrieve the corresponding ASCII value. Then if it is in lower case add 32 to its ASCII value and display it.

0

Adding 32 to get upper case only works for the 26 letters of the English alphabet. Use toUpperCase(...) to convert accented characters, other languages and scripts to upper case properly.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.