Set a Text Input into Lowercase and Uppercase Value in Java

0
109

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.

  1. //Declaring a String variables
  2. String up;
  3. String lo;

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

  1. //Initializing the converting the text value
  2.  
  3. up = jTextField1.getText().toUpperCase();
  4.  
  5. lo = jTextField1.getText().toLowerCase();

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

  1. //Displaying the output
  2.  
  3. jTextField2.setText(up);
  4. jTextField3.setText(lo);

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

8. Complete Source Code.

  1. //Declaring a String variables
  2.  
  3. String up;
  4.  
  5. String lo;
  6.  
  7. //Initializing the converting the text value
  8.  
  9. up = jTextField1.getText().toUpperCase();
  10.  
  11. lo = jTextField1.getText().toLowerCase();
  12.  
  13. //Displaying the output
  14.  
  15. jTextField2.setText(up);
  16.  
  17. jTextField3.setText(lo);

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:

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here