List of utility methods to do JTextComponent Delete
void | appendText(JTextComponent fld, String s, String delimiter) _more_ String t = fld.getText(); while (t.endsWith(" ")) { t = t.substring(0, t.length() - 1); if ((t.length() > 0) && !t.endsWith(delimiter)) { t = t + delimiter; t = t + s; ... |
void | delete(JTextComponent textComponent) Deletes the selected text in a text component. textComponent.replaceSelection(EMPTY); |
void | deleteLine(JTextComponent textComponent) delete Line char newLine = '\n'; String _newLine = "\n"; int caretIndex = textComponent.getCaretPosition(); String text = textComponent.getText(); StringBuilder sb = new StringBuilder(text); int endOfLineIndexBefore = -1; int endOfLineIndexAfter = sb.indexOf(_newLine, caretIndex); char[] textChars = text.toCharArray(); ... |
void | deleteSelection(JTextComponent textComponent) delete Selection textComponent.replaceSelection("");
|
void | deleteWord(JTextComponent textComponent) delete Word char space = ' '; String _space = " "; int caretIndex = textComponent.getCaretPosition(); String text = textComponent.getText(); StringBuilder sb = new StringBuilder(text); int startOfWordIndex = -1; int endOfWordIndex = sb.indexOf(_space, caretIndex); char[] textChars = text.toCharArray(); ... |
Rectangle | modelToView(final JTextComponent scrollableComponent, int pos) model To View try { return scrollableComponent.modelToView(pos); } catch (BadLocationException exception) { throw new RuntimeException(exception); |