GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Capturing all type of inputs in a JTextField Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Capturing all type of inputs in a JTextField" Watch "Capturing all type of inputs in a JTextField" New topic
Author

Capturing all type of inputs in a JTextField

John Fernandas
Greenhorn

Joined: Dec 15, 2011
Posts: 3
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

Joined: May 03, 2008
Posts: 4572
    
    5

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


luck, db
There are no new questions, but there may be new answers.
 
GeeCON Prague 2014
 
subject: Capturing all type of inputs in a JTextField