Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Input mask for JTextField

  Asked By: Keana    Date: Oct 11    Category: Java    Views: 3110
  

I am building a GUI that gets information from the user. I
want to ask such things as House Number and Phone Number. I want to
stop the user from entering characters into the JTextField and would
like to limit the input to Integer; can anybody help me?
Thanks

Share: 

 

1 Answer Found

 
Answer #1    Answered By: May Hansen     Answered On: Oct 11

U can add the focusLostListener method to the text field u want to validate.
This focus lost will be called when the focus has been lost from the
textfiled u want to validate. This can be like when u pressed tab from the
textfield or u press on some other component in the dialog or frame this
method will be called.
If u want to restrict the user  while typing, then u need to add a keyPressed
or keyReleased event. it will validate every time u press or release the
key.

u can find the method signature and arguments in the Java doc API
http://java.sun.com/j2se/1.3/docs/api/

 
Didn't find what you were looking for? Find more on Input mask for JTextField Or get search suggestion and latest updates.




Tagged: