restricting text and forcing UPPERCASE in an applet


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: restricting text and forcing UPPERCASE in an applet

  1. #1
    Join Date
    Mar 2003
    Posts
    6

    restricting text and forcing UPPERCASE in an applet

    I have an applet where the users can enter anything into a text field. I would like to restrict user input to "Y" and "N" only. Also I would like them to be able to enter"y" and the text is converted into uppercase "Y". I'm using Sun One studio to develop in
    Thanks for any help
    Dan

  2. #2
    Join Date
    Mar 2003
    Posts
    32
    You can use the toUpperCase function of strings to convert everything to uppercase. Just take their text and use the fnction, Eg:

    String upperCase = theirText.toUpperCase();

    Hope this helps!

  3. #3
    Join Date
    Mar 2003
    Posts
    17
    if you are using JDK 1.4 you could try to see if JFormattedTextField will do what you wish.

    Otherwise, perhaps implement a textListener to activate when the content of the text field changes and if the text entered is not y/Y or n/N you can set it back to empty string and as MasterOfSouls stated, you can use str.toUpperCase()
    Laziness is a virtue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center