Refine search
/** * Gets the whole string from the passed DocumentFilter replace. */ static String getReplacedText(DocumentFilter.FilterBypass fb, int offset, int length, String str) throws BadLocationException { Document doc = fb.getDocument(); StringBuilder sb = new StringBuilder(doc.getText(0, doc.getLength())); sb.replace(offset, offset + length, str); return sb.toString(); } }
if (pattern != null && pattern.length() > 0) { try { Document doc = textComponent.getDocument(); doc.getText(0, doc.getLength(), SEGMENT); pos += backwards ? -1 : 1; int length = textComponent.getDocument().getLength(); if (pos > length) { pos = wrapped ? 0 : length;
private String getWord(int offset) { try { int start = Utilities.getWordStart(textComponent, offset); int end = Utilities.getWordEnd(textComponent, offset); return textComponent.getDocument().getText(start, end - start + 1).trim(); } catch (BadLocationException e) { e.printStackTrace(); } return null; }
panel.add(textField); PlainDocument doc = (PlainDocument) textField.getDocument(); doc.setDocumentFilter(new MyIntFilter()); sb.append(doc.getText(0, doc.getLength())); sb.insert(offset, string); sb.append(doc.getText(0, doc.getLength())); sb.replace(offset, offset + length, text); Document doc = fb.getDocument(); StringBuilder sb = new StringBuilder(); sb.append(doc.getText(0, doc.getLength())); sb.delete(offset, offset + length);
private String getRowText(int offset) { try { int rowStart = Utilities.getRowStart(textComponent, offset); int rowEnd = Utilities.getRowEnd(textComponent, offset); return textComponent.getDocument().getText(rowStart, rowEnd - rowStart + 1); } catch (BadLocationException e) { e.printStackTrace(); } return null; } }
public void saveUntaggedContents(File file) { try { String contents; if (editorPane.getContentType().equals("text/html")) { contents = editorPane.getText(); } else { Document doc = editorPane.getDocument(); contents = doc.getText(0, doc.getLength()); } saveFile(file, contents); saveUntagged.setEnabled(true); loadedFile = file; } catch (Exception e) { throw new RuntimeException(e); } }
Document doc = target.getDocument(); Caret caret = target.getCaret(); int dot = caret.getDot(); if (dot != mark) { doc.remove(Math.min(dot, mark), Math.abs(dot - mark)); } else if (dot < doc.getLength()) { int delChars = 1; if (dot < doc.getLength() - 1) { String dotChars = doc.getText(dot, 2); char c0 = dotChars.charAt(0); char c1 = dotChars.charAt(1);
if ((target != null) && (target.isEditable())) { try { Document doc = target.getDocument(); Caret caret = target.getCaret(); int dot = caret.getDot(); String dotChars = doc.getText(dot - 2, 2); char c0 = dotChars.charAt(0); char c1 = dotChars.charAt(1);
private void saveUntaggedContents(File file) { try { String contents; if (editorPane.getContentType().equals("text/html")) { contents = editorPane.getText(); } else { Document doc = editorPane.getDocument(); contents = doc.getText(0, doc.getLength()); } saveFile(file, contents); saveUntagged.setEnabled(true); loadedFile = file; } catch (Exception e) { throw new RuntimeException(e); } }
PlainDocument doc = (PlainDocument) textfield.getDocument(); doc.setDocumentFilter(new TextLengthDocFilter(3)); String oldText = doc.getText(0, doc.getLength()); StringBuilder sb = new StringBuilder(oldText); sb.insert(offset, string); throws BadLocationException { Document doc = fb.getDocument(); String oldText = doc.getText(0, doc.getLength()); StringBuilder sb = new StringBuilder(oldText); public void remove(FilterBypass fb, int offset, int length) throws BadLocationException { Document doc = fb.getDocument(); String oldText = doc.getText(0, doc.getLength()); StringBuilder sb = new StringBuilder(oldText);
Document doc = textComponent.getDocument(); rootElement = doc.getDefaultRootElement(); doc.getText(currentLineStart+startingOffset, currentLineEnd-(currentLineStart+startingOffset), currentLineSeg); } catch (BadLocationException ble) { currentPos++; try { doc.getText(currentLineStart+startingOffset, currentPos, currentLineSeg); } catch (BadLocationException ble) { System.err.println(ble); doc.getText((currentLineStart+startingOffset), currentPos, currentLineSeg); } catch (BadLocationException ble) { System.err.println("BadLocationException in print (a):");
private void update(DocumentEvent event) { String newValue = ""; try { Document doc = event.getDocument(); newValue = doc.getText(0, doc.getLength()); } catch (BadLocationException e) { Luyten.showExceptionDialog("Exception!", e); } if (newValue.length() > 0) { int index = targetList.getNextMatch(newValue, 0, Position.Bias.Forward); if (index < 0) { index = 0; } targetList.ensureIndexIsVisible(index); String matchedName = targetList.getModel().getElementAt(index).toString(); if (newValue.equalsIgnoreCase(matchedName)) { if (index != targetList.getSelectedIndex()) { SwingUtilities.invokeLater(new ListSelector(index)); } } } }
public String call() { Document doc = component.getDocument(); try { return doc.getText(0, doc.getLength()); } catch (BadLocationException e) { e.printStackTrace(); return ""; } } });
/** Get the word around the given position . * @param c component to work with * @param offset position in document - usually the caret.getDot() * @return the word. */ public static String getWord(JTextComponent c, int offset) throws BadLocationException { int[] blk = getIdentifierBlock(c, offset); Document doc = c.getDocument(); return (blk != null) ? doc.getText(blk[0], blk[1] - blk[0]) : null; }
/** * Reads the single character at the current position in the document. */ @Override public int read() { if(position>=document.getLength()) { return -1; // Read past end of document. } try { document.getText((int)position,1, segment); position++; return segment.array[segment.offset]; } catch (BadLocationException ble) { /* Should never happen?? */ ble.printStackTrace(); return -1; } }
private String getWordToComplete() { try { int index = getWordIndex(); int caretIndex = getEffectiveCaretPosition(); return textComponent.getDocument().getText(index, caretIndex - index); } catch (BadLocationException e) { logger.error("A BadLocationException was thrown when the auto-completer was " + "retrieving the word to complete.", e); return ""; } }
public int read(char[] cbuf, int off, int len) { int k; if(position>=document.getLength()) { return -1; // Read past end of document. if((position+k)>=document.getLength()) { k = document.getLength() - (int)position; document.getText((int)position, k, segment); position += k; System.arraycopy(segment.array,segment.offset,
private String getWordToComplete() { try { int index = getWordIndex(); int caretIndex = getEffectiveCaretPosition(); return textComponent.getDocument().getText(index, caretIndex - index); } catch (BadLocationException e) { logger.error("A BadLocationException was thrown when the auto-completer was " + "retrieving the word to complete.", e); return ""; } }