Solved

JAVA -- Textbox "KeyPress" EVENT on two textboxes

Posted on 2009-07-16
1
590 Views
Last Modified: 2012-05-07
I have two textboxes (TextBox1 & TextBox2)

Convert below C# code into JAVA
so I can use this one "TextBox_KeyPress"
EVENT on both textboxes.
------------------------------------------------------------  
private void TextBox_KeyPress(
      System.Object sender, KeyPressEventArgs e)
    {
      if (Char.IsLetter(e.KeyChar) && Char.IsLower(e.KeyChar)
        || char.IsWhiteSpace(e.KeyChar))
      {
        ((TextBox)sender).AppendText(
          Char.ToUpper(e.KeyChar).ToString());
        e.Handled = true;
      }
    }
0
Comment
Question by:finance_teacher
[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
1 Comment
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 24870730
Try something like the following :
    private class TextBoxKeyPress extends KeyAdapter {
        public void keyPressed(KeyEvent e) {
            char c = e.getKeyChar();
 
            if ((Character.isLetter(c) && Character.isLowerCaseChar(c)) ||
                    Character.isWhiteSpaceChar(c)) {
                textBox.append("" + Character.toUpperCase(c));
            }
        }
    }   

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange router problem - can't access hotmail.com 14 108
Java import explained 4 47
Which is best Image Resizing Web service 11 39
junit initializtion error 2 20
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

734 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