Is it to possible to capitalize the letters in a Textfield as they are being typed by the user in Java?
E.g. The user would type 'hello' and 'HELLO' would appear in the Textfield.
(Odd request and I don't like the idea either).
Is it to possible to capitalize the letters in a Textfield as they are being typed by the user in Java?
E.g. The user would type 'hello' and 'HELLO' would appear in the Textfield.
(Odd request and I don't like the idea either).
Format JTextField's text to uppercase
Uses DocumentFilter
or
How to Use Formatted Text Fields
Uses MaskFormatter
This is probably an inefficient way to do it
but you could have a section in your KeyTyped event handler
if(event.getSource() == capitalTextArea) {
String text = capitalTextArea.getText();
if(Character.isLowerCase(text.charAt(text.length()-1))) {
capitalTextArea.setText(text.toUpperCase());
}
}
I might have syntatical mistakes, but that's the apporach i'd take