public void focusMoved(boolean gained) {
        focus = gained;
        controller.focusMoved(gained);
        if (gained) {
            // select all text
            setCaretPosition(0);
            moveCaretPosition(getText().length());
        }
    }
public void focusMoved(boolean gained)