DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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.

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links