I have a JTable which has 2 columns. One of these columns is represented by a JTextField and the other one by a radio button.
The model is populated in this way:
model.addRow(new Object[]{radioButton, ""});
Associated with the JTextField there is a cell editor like this:
class MyCellEditor extends DefaultCellEditor {
MyCellEditor(JTextField textField) {
super(textField);
textField.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
// do something if focus is lost
}
@Override
public void focusGained(FocusEvent e) {
}
});
}
When I click on the JTextField cell I get a "blinking" cursor as expected so I can input my text in. Anyway if I click anywhere else in the main window I would expect that "focusLost(...)" method has been called but that happens only if I "play" a bit around in the window (like clicking in and out the jtextfield a few times).
Why the component doesn't lose the focus just after the first click to another external component?