@Override
 public void focusGained(FocusEvent e) {
   if (!pressed) {
     init();
     findSelection(0);
   }
 }
 @Override
 public void mouseReleased(MouseEvent e) {
   init();
   index = findSelection(getCaretPosition());
   pressed = false;
 }
 @Override
 public void mousePressed(MouseEvent e) {
   init();
   pressed = true;
 }