Java Utililty Methods JTextComponent Delete

List of utility methods to do JTextComponent Delete

Description

The list of methods to do JTextComponent Delete are organized into topic(s).

Method

voidappendText(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;
...
voiddelete(JTextComponent textComponent)
Deletes the selected text in a text component.
textComponent.replaceSelection(EMPTY);
voiddeleteLine(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();
...
voiddeleteSelection(JTextComponent textComponent)
delete Selection
textComponent.replaceSelection("");
voiddeleteWord(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();
...
RectanglemodelToView(final JTextComponent scrollableComponent, int pos)
model To View
try {
    return scrollableComponent.modelToView(pos);
} catch (BadLocationException exception) {
    throw new RuntimeException(exception);