DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Posts
    29

    activating a JTextField

    Hey,

    I'm programming an interface with several JTextFields, and some error checking once the user hits submit. IT goes through each text field, and if it detects a problem it returns to the form so the user can make the necessary corrections. The problem is that I want the cursor to be in the correct TextField. I've got something along the lines of:

    TextField.setCaretPosition(TextField.getText().length());

    but no cursor seems to be placed into the textfield. My guess is there must be an activateTextfield() function or something, but I can't find anything of the kind in the documentation. Does anyone know how to do this?

    Gibran

  2. #2
    Join Date
    Jun 2004
    Posts
    14
    Look into focus traversal (to get the cursor, the textfield needs to have the keyboard focus).

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