Set a Text Input into Lowercase and Uppercase Value in Java

0
1414

This tutorial is all about set a Text Input into Lowercase and Uppercase Value using Java. The keyboard supports these two features, the lowercase and uppercase but after completing this tutorial, you can directly convert the user input into Lowercase or Uppercase value.

If one character is a lowercase or uppercase, the program directly convert it into uppercase or lower case value. Below are the steps on how to convert the text input into lowercase or uppercase.

Set a Text Input into Lowercase and Uppercase Value in Java Steps

  1. Create a new Form inside your source package. Just name the form what you want to name it. In my case, I named my form using “Convert Text Input”.

2. Design your form just look like the image below.

3. Generate a KeyReleased Event into your input text field.

4. Insert the codes below inside your new generated keyReleased Event. The codes is use to declare a string variables.

[java]//Declaring a String variables
String up;
String lo;[/java]

5. Insert the codes below after step 4. The codes will initialize the variables and convert it into uppercase and lowercase.

[java]//Initializing the converting the text value

up = jTextField1.getText().toUpperCase();

lo = jTextField1.getText().toLowerCase();[/java]

6. Insert the codes below after step 5. The codes will display the converted value into text field elements.

[java]//Displaying the output

jTextField2.setText(up);
jTextField3.setText(lo);[/java]

7. Run your program and the output should look like the image below.

8. Complete Source Code.

[java]//Declaring a String variables

String up;

String lo;

//Initializing the converting the text value

up = jTextField1.getText().toUpperCase();

lo = jTextField1.getText().toLowerCase();

//Displaying the output

jTextField2.setText(up);

jTextField3.setText(lo);[/java]

This features is always available in all applications either a desktop apps or mobile apps. By adding these features, the user of your program is not worry about what they are inputted into the program because it is already converted into a lowercase or uppercase value.

Related Articles You May Like:

Looking for more source code? Type your keyword here here!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.