Java AWT tutorial for lower case to uppercase conversion: This tutorial deals with changing upper case to lower case or lower case to upper case values in java using AWT program. It is used to change the words or text will convert the case value by using this program. It makes to change the written upper case to lower case easily or vice versa. For example your entered text is “students3k” and after execution it will display as “STUDENTS3K”.
Read: Change Label Text in Java AWT with example program
Changing Case values in AWT:
Q: How to convert lowercase to uppercase Text in java AWT?
[Useful: C Programming Guide] & [IT Companies List]
//Import Statements import java.awt.*; import java.awt.event.*; //Class method class ChangeCase extends Frame implements ActionListener { //Variable declaration Checkbox ch1,ch2,ch3,ch4,ch5; CheckboxGroup chg; Button bu; TextArea tax; public ChangeCase(String title)//Main method { super(title); chg=new CheckboxGroup();//Object creation ch1=new Checkbox("SentenceCase",chg,false); ch2=new Checkbox("lowercase",chg,false); ch3=new Checkbox("UPPERCASE",chg,false); ch4=new Checkbox("TitleCase",chg,false); ch5=new Checkbox("tOGGLEcASE",chg,false); bu=new Button("Apply"); tax=new TextArea(); setLayout(new GridLayout(7,1)); add(ch1); add(ch2); add(ch3); add(ch4); add(ch5); add(bu); add(tax); bu.addActionListener(this); // addWindowListener(new Mywindow()); setSize(400,400); setVisible(true); } // © http://students3k.com – Karhtikh venkat public void actionPerformed(ActionEvent e) { if(e.getSource()==bu)//Decision making statement { int i; StringBuffer str=new StringBuffer(ta.getText()); String s; if(ch1.getState()==true) { str.insert(0,Character.toUpperCase(str.charAt(0))); str.deleteCharAt(1); for(i=0;i<str.length();i++)//For statement { if(str.charAt(i)=='.') { str.insert(i+2,Character.toUpperCase(str.charAt(i+2))); str.deleteCharAt(i+3); } } tax.setText(new String(str)); } else if(ch2.getState()==true) { s=tax.getText(); s=s.toLowerCase(); tax.setText(s); } else if(ch3.getState()==true) { s=tax.getText(); s=s.toUpperCase(); tax.setText(s); } else if(ch4.getState()==true) { s=tax.getText(); s=s.toLowerCase(); str=new StringBuffer(s); // © http://students3k.com – Karhtikh venkat str.insert(0,Character.toUpperCase(str.charAt(0))); str.deleteCharAt(1); for(i=0;i<str.length();i++) { if(Character.isSpace(str.charAt(i))==true) { str.insert(i+1,Character.toUpperCase(str.charAt(i+1))); str.deleteCharAt(i+2); } } tax.setText(new String(str)); } else { s=tax.getText(); s=s.toUpperCase(); str=new StringBuffer(s); str.insert(0,Character.toLowerCase(str.charAt(0))); str.deleteCharAt(1); for(i=0;i<str.length();i++) { if(Character.isSpace(str.charAt(i))==true) { str.insert(i+1,Character.toLowerCase(str.charAt(i+1))); str.deleteCharAt(i+2); } } tax.setText(new String(str)); } } // © http://students3k.com – Karhtikh venkat } public static void main(String a[]) { ChangeCase n=new ChangeCase("ChangeCase"); } }