Examples of insertString()


Examples of javax.swing.text.Document.insertString()

   * Start a new line.
   */
  protected void insertNewline() {
    final Document doc = textPane.getDocument();
    try {
      doc.insertString(doc.getLength(), "\r\n", getStyle(Color.black, "normal"));
    } catch (final BadLocationException e) {
      logger.error("Couldn't insert initial text.", e);
    }
  }

View Full Code Here

Examples of javax.swing.text.Document.insertString()

            if (removeLen > 0) {
                doc.remove(0, removeLen);
            }

            Position end = doc.getEndPosition();
            doc.insertString(end.getOffset() - 1, str, null);
        } catch (BadLocationException ble) {
            // should never happen
            logger.log(Level.WARNING, "Bad location", ble);
            return;
        }
View Full Code Here

Examples of javax.swing.text.Document.insertString()

                    return;

                try {
                    String before = doc.getText(p-1, 1);
                    doc.remove(p-1, 1);
                    doc.insertString(p, before, null);
                    textComponent.setCaretPosition(p);
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
            }
View Full Code Here

Examples of javax.swing.text.Document.insertString()

            if(removeStartIndex+removeLength > doc.getLength())
                removeLength--;

            if(sourceRule.getStartIndex()>targetRule.getStartIndex()) {
                doc.remove(removeStartIndex, removeLength);
                doc.insertString(targetInsertionIndex, "\n"+sourceRuleText, null);
                window.setCaretPosition(targetInsertionIndex);
            } else {
                doc.insertString(targetInsertionIndex, "\n"+sourceRuleText, null);
                doc.remove(removeStartIndex, removeLength);
                window.setCaretPosition(targetInsertionIndex-removeLength);
View Full Code Here

Examples of javax.swing.text.Document.insertString()

            if(sourceRule.getStartIndex()>targetRule.getStartIndex()) {
                doc.remove(removeStartIndex, removeLength);
                doc.insertString(targetInsertionIndex, "\n"+sourceRuleText, null);
                window.setCaretPosition(targetInsertionIndex);
            } else {
                doc.insertString(targetInsertionIndex, "\n"+sourceRuleText, null);
                doc.remove(removeStartIndex, removeLength);
                window.setCaretPosition(targetInsertionIndex-removeLength);
            }
            return true;
        } catch (BadLocationException e) {
View Full Code Here

Examples of javax.swing.text.Document.insertString()

    public void completePartialWord(String word) {
        try {
            Document doc = getTextComponent().getDocument();
            doc.remove(insertionStartIndex, insertionEndIndex-insertionStartIndex);
            doc.insertString(insertionStartIndex, word, null);
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of javax.swing.text.Document.insertString()

                        // u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
View Full Code Here

Examples of javax.swing.text.Document.insertString()

                        // u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
View Full Code Here

Examples of javax.swing.text.Document.insertString()

     */
    public void replaceText(String text, int start_pos, int end_pos) {
        try {
            final Document doc = ((JTextArea) peerComponent).getDocument();
            doc.remove(start_pos, end_pos - start_pos);
            doc.insertString(start_pos, text, null);
        } catch (BadLocationException ex) {
            throw new RuntimeException(ex);
        }
    }

View Full Code Here

Examples of javax.swing.text.Document.insertString()

    }


    private void processOutput(String text, AttributeSet attribs) throws BadLocationException {
        Document doc = output.getDocument();
        doc.insertString(0, text, attribs);
        output.setCaretPosition(0);
    }

}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.