Solved

Converting Lowercase  to Uppercase Character.

Posted on 2000-02-27
10
698 Views
Last Modified: 2013-12-03
Hi!
In Java, is there any options to convert the lowercase character to uppercase character once typing in the textfied.  If yes, mind show me the command line.  Thanks.
Regards,
Huang Aun.
0
Comment
Question by:HuangAun
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 1

Expert Comment

by:technoman
ID: 2563619
you can use stringvar.toUpperCase()

where stringvar is a string variable.
0
 
LVL 3

Accepted Solution

by:
rjackman earned 10 total points
ID: 2563631
hi there try this out

import java.awt.*;
import java.awt.event.*;
public class TestString extends Frame implements ActionListener  
{
      private TextField tf;
      
      public TestString()
      {
            this.setSize(100,100);
            tf = new TextField(8);
            tf.addActionListener(this);
            this.add(BorderLayout.CENTER,tf);
                  
      }
      public void actionPerformed(ActionEvent e)
      {
            //enter the value & then press enter button will convert upper
            //case value to lower case
            String a = tf.getText();
            String b = tf.getText();
            int x = b.compareTo(a.toLowerCase());
            if(x == 0 )
            {
            b = a.toUpperCase();
                  tf.setText(b);
            }
            
      }
      public static void main(String args[])
      {
            TestString ts = new TestString();
            ts.setVisible(true);
      }
}
0
 
LVL 2

Expert Comment

by:muraliram
ID: 2563946
If you want to convert the text as you are typing try the following.

import java.awt.*;
import java.awt.event.*;

public class uppercase extends Frame implements TextListener  
{
TextField t;

public uppercase()
{
t = new TextField(20);
setLayout(new FlowLayout());
this.setSize(200,200);
add(t);
t.addTextListener(this);
this.setVisible(true);
}

public void textValueChanged(TextEvent e)
{
t.setText(t.getText().toUpperCase())

}
public static void main(String args[])
{
uppercase u = new uppercase();
}
}

This will work properly if you want to convert while typing itself.I think this is your requirement.

Good Luck
muraliram
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 1

Expert Comment

by:jadrek85
ID: 2564221
Hi Muraliram,
As for as I know, there is no event called textValiueChanged. We can use the following line of code in text box keyRelease Event. Try this, this is working.


 void txtStTime_keyReleased(KeyEvent e) {
    txtStTime.setText(txtStTime.getText().toUpperCase()) ;
  }

Cheers,

Jadhav
0
 
LVL 2

Expert Comment

by:muraliram
ID: 2564367
Dear jadrek85,

Copy the above code and try it. There is an event called textValueChanged.
There is nothing wrong with that event.

muraliram
0
 
LVL 1

Expert Comment

by:jadrek85
ID: 2564514
Hi Muraliram,

You are right. I didn't observer that you are using awt component. But, the entered characters are padding left hand side of the text box and the text box area is blinking. I think you may need to validate and repaint the text box. Thanks for giving clarification. Keep it up.

Cheers,
Jadhav
0
 
LVL 2

Expert Comment

by:muraliram
ID: 2564738
Dear jadrek85,

Thanks. I have noticed the problem of blinking.

Bye
muraliram
0
 

Author Comment

by:HuangAun
ID: 2567505
The textField only can support for a single chracter and not a word.
Anyway, Rjackman suggestion work but need to do a little bit modification to support the string even lowercase or uppercase.  I accept Rjackman suggection but where can I do it.
0
 

Author Comment

by:HuangAun
ID: 2567512
Thanks.  it work's.
But need to modify a little bit to convert it even combination from lowercase and uppercase.
Thanks a lot.
0
 
LVL 3

Expert Comment

by:rjackman
ID: 2567673
hi HuangAun
thanx for appreciting my comment
in ur problem statement u have mentioned on for lowercase conversion to uppercase that's why i havenot considered the mixed case if u want can post the code for same
thanx again
---RickyJackman
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
micro services vs rest web services 16 104
how do i compare an object based on two fields 6 53
null output 3 25
mysql jsp example issue 32 33
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question