Code example for JTextComponent

Methods: addFocusListener

0
public class FocusLostTextComponentAdapter extends AbstractValueModelAdapter implements FocusListener {
    private final JTextComponent control;
 
    public FocusLostTextComponentAdapter(JTextComponent component, ValueModel valueModel) {
        super(valueModel);
        Assert.notNull(component);
        this.control = component;
        this.control.addFocusListener(this);
        initalizeAdaptedValue(); 
    } 
 
    protected void valueModelValueChanged(Object value) { 
        control.setText((String)value);
    } 
 
    public void focusLost(FocusEvent e) {
        adaptedValueChanged(control.getText());
    } 
 
    public void focusGained(FocusEvent e) {