1
public void actionPerformed(ActionEvent ae){
   String userName = userNameTxt.getText();
   char[] pass = password.getPassword();

}

I want to validate the above fields( its username and password) I want to take only alohabet(a-z) in username and a-z, 0-9 in password how to do this ? I am new to swing

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
newBrain
  • 103
  • 1
  • 1
  • 9
  • please whats this question has something with html – mKorbel Mar 06 '13 at 06:42
  • @mKorbel: no this question has nothing with html – newBrain Mar 06 '13 at 06:48
  • 3
    What does "verify" mean to you? What is wrong with the functionality of an InputVerifier? What type of functionality are you looking for? – camickr Mar 06 '13 at 06:56
  • Yup, what is it you are trying to do. The answer is "yes" and "no" – MadProgrammer Mar 06 '13 at 06:57
  • 1
    Your edits makes your question clearer. Add a DocumentFilter to the text fields. This way you can prevent the user from entering unwanted characters. Read the section from the Swing tutorial on [Implementing a Document Filter](http://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html#filter) for more information. – camickr Mar 06 '13 at 17:10

0 Answers0