Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capitalize all letters in a Textfield in Java

Tags:

java

text

swing

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).

like image 217
Gordon Avatar asked May 20 '10 14:05

Gordon


People also ask

How do you capitalize every letter in Java?

String string = "Contains some Upper and some Lower."; String string2 = string. toUpperCase(); String string3 = string. toLowerCase(); These two methods transform a string into all uppercase or all lowercase letters.

Why is string capitalize in Java?

The String type is capitalized because it is a class, like Object , not a primitive type like boolean or int (the other types you probably ran across). As a class, the String follows the Naming Convention for Java proposed by Sun.

What is the difference between TextField and JTextField in Java?

TextField used the text of the field as the command string for the ActionEvent . JTextField will use the command string set with the setActionCommand method if not null , otherwise it will use the text of the field as a compatibility with java. awt.


1 Answers

Format JTextField's text to uppercase

Uses DocumentFilter

or

How to Use Formatted Text Fields

Uses MaskFormatter

like image 149
Glennular Avatar answered Sep 30 '22 06:09

Glennular