Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Capturing all type of inputs in a JTextField

 
John Fernandas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i used 4 JTextField in my swing form.i need to do is moving the focus from one JTextField to the other JTextField by hit the enter key and tab key.i done it successfully but the problem was the JTextField allows only numeric values if i give any value other than numeric value in the JTextfield the JTextField is locked and there is no focus transfer happen between the JTextFields.the code i was used



 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, see the API for the requestFocus() method and follow the advice given there about which method you should use instead.

the problem was the JTextField allows only numeric values if i give any value other than numeric value in the JTextfield the JTextField is locked and there is no focus transfer happen between the JTextFields.the code i was used

If you didn't want that behavior, then why did you code for it? Where did you get this line?


Trying to create a program with just two keystrokes** doesn't work. You have to buckle down and learn to understand the code you're using. And the only way to get there is to first write your own code.

Oh, and please BeForthrightWhenCrossPostingToOtherSites
http://stackoverflow.com/questions/8586013/transfer-the-focus-among-the-jtextfields-in-java-swing
http://forums.oreilly.com/topic/71434-generic-class-in-java/
http://www.dreamincode.net/forums/topic/260520-writing-generic-class-with-parameter-in-java/

This also appears to be a continuation of your earlier question, and should have been posted in the same thread.
http://www.coderanch.com/t/561993/GUI/java/Focus-Gained-event
Also, you should have the courtesy to replay to responses on any thread you start.


** Ctrl+C, Crtl+V
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic