use the following code to validate a user data in textbox and if the data do not match with
database then got the focus back to field with a dialog box.
But When yearfield get lost focus by pressing tab key then dialog box come up but my ok
does not make any effect .It is there as it is .I think it is losing focus that's why it come
up.please rectify my problem.
public void focusGained(FocusEvent fe){}
public void focusLost(FocusEvent e){
Object source1=e.getSource();
System.out.println(source1==yearfield);
if(source1==yearfield){
aa=yearfield.getText().trim();
System.out.println(aa);
if (aa.equals("__/__/____")){
JOptionPane.showMessageDialog( this, "This is a
dialog" );
yearfield.requestFocus();
flag14=false;
a2=""; }
}
}
When I am only using focus listener than Caret is blinking one time in time field and one
time in yearfield.
please help
java gurus.