void removeText() { if ((p0 != null) && (p1 != null) && (p0.getOffset() != p1.getOffset())) { try { Document doc = c.getDocument(); doc.remove(p0.getOffset(), p1.getOffset() - p0.getOffset()); } catch (BadLocationException e) { } } }
@Override protected void exportDone(JComponent source, Transferable data, int action) { if (action == TransferHandler.MOVE) { JTextPane aTextPane = (JTextPane) source; int sel_start = aTextPane.getSelectionStart(); int sel_end = aTextPane.getSelectionEnd(); Document doc = aTextPane.getDocument(); try { doc.remove(sel_start, sel_end - sel_start); } catch (BadLocationException e) { Debug.error(me + "exportDone: Problem while trying to remove text\n%s", e.getMessage()); } } }
private void expandTab() throws BadLocationException { int pos = getCaretPosition(); Document doc = getDocument(); doc.remove(pos - 1, 1); doc.insertString(pos - 1, _tabString, null); }