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