?
Solved

Converting Lowercase  to Uppercase Character.

Posted on 2000-02-27
10
Medium Priority
?
720 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 30 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

762 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