godcomplex
Programmer
Hello All,
I am having a problem catching the focus gained event in a JTextField. I have extended JTextField so that I can enter masks into the JTextField (the class was written before the realease of 1.4). The problem is that when the field gains focus, the caret moves to the end of the JTextField. This is the case because the text field already contains characters for the mask. For instance, the text field for a ssn number would contain " - - " initially. I have implemented the FocusListener interface and overwritten the focusGained method to reset the caret poistion to my own desired position, but it seems that although my code is being executed, the event is later processed by the system and the caret is moved back to the end of the text field. I have noticed that this is also a problem with the JFormattedTextField.
Is there any way to stop focus events from being processed any further? The consume() method on FocusEvent is not accessable from the listener.
-gc
I am having a problem catching the focus gained event in a JTextField. I have extended JTextField so that I can enter masks into the JTextField (the class was written before the realease of 1.4). The problem is that when the field gains focus, the caret moves to the end of the JTextField. This is the case because the text field already contains characters for the mask. For instance, the text field for a ssn number would contain " - - " initially. I have implemented the FocusListener interface and overwritten the focusGained method to reset the caret poistion to my own desired position, but it seems that although my code is being executed, the event is later processed by the system and the caret is moved back to the end of the text field. I have noticed that this is also a problem with the JFormattedTextField.
Is there any way to stop focus events from being processed any further? The consume() method on FocusEvent is not accessable from the listener.
-gc