t.getDocument().remove(pos, len); t.setCaretPosition(pos);
pos--; t.getDocument().remove(pos, 1); Caret c = t.getCaret(); c.setDot(pos); c.setMagicCaretPosition(t.modelToView(pos).getLocation());
      public void actionPerformed(ActionEvent event)      {        JTextComponent t = getTextComponent(event);        if (t != null)          {            try              {                int pos = t.getSelectionStart();                int len = t.getSelectionEnd() - pos;                                if (len > 0)                  {                    t.getDocument().remove(pos, len);                    t.setCaretPosition(pos);                  }                else if (pos > 0)                    t.getDocument().remove(pos - 1, 1);              }            catch (BadLocationException e)              {                // FIXME: we're not authorized to throw this.. swallow it?              }          }      }