• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Capturing all type of inputs in a JTextField

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
https://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
 
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic