Nagendra Shastry wrote:
I have a text box and a button. Once the text box looses focus, focus has to be set to button. I have written the following code. But it isn't working. What is the problem?
txtMod1.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent evt) {
orderCreationAction.setOrderValueReturned(Integer.valueOf(0));
cleanModelData(false);
btnModelSearch.setFocus();
}
}
Try to place the setFocus() call in a SwingUtilities.invokeLater() call.