Package javax.swing.text

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


        if ( CDATA_NAME.equals(name) ) {
            document.insertString(pos, "<![CDATA[  ]]>".substring(this.prefixLength), null);
            xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 4 );
        } else if ( XML_COMMENT_NAME.equals(name) ) {
            document.insertString(pos, "<!--  -->".substring(this.prefixLength), null);
            xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 4 );
        } else {
            ElementInfo info = DefinitionResolver.getElementInfo(name);
            if (info != null) {
                String template = info.getTemplate(true).substring(this.prefixLength);
View Full Code Here


            xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 4 );
        } else {
            ElementInfo info = DefinitionResolver.getElementInfo(name);
            if (info != null) {
                String template = info.getTemplate(true).substring(this.prefixLength);
                document.insertString(pos, template, null);
                int closingIndex = template.lastIndexOf("</");
                if (closingIndex >= 0) {
                    xmlPane.setCaretPosition( xmlPane.getCaretPosition() - template.length() + closingIndex );
                }
            }
View Full Code Here

                    if (code == MenuKeyEvent.VK_BACK_SPACE) {
                        if ( pos > 0 && document.getLength() > 0 ) {
                            document.remove(pos - 1, 1);
                        }
                    } else {
                        document.insertString(pos, String.valueOf(ch), null);
                    }
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
                popupMenu.setVisible(false);
View Full Code Here

   */
  protected void insertHeader(final String header) {
    final Document doc = textPane.getDocument();
    try {
      if (header.length() > 0) {
        doc.insertString(doc.getLength(), "<" + header + "> ",
            textPane.getStyle("header"));
      }
    } catch (final BadLocationException e) {
      logger.error("Couldn't insert initial text.", e);
    }
View Full Code Here

   */
  protected void insertTimestamp(final String header) {
    final Document doc = textPane.getDocument();
    try {
      if (header.length() > 0) {
        doc.insertString(doc.getLength(), header,
            textPane.getStyle("timestamp"));
      }
    } catch (final BadLocationException e) {
      logger.error("Couldn't insert initial text.", e);
    }
View Full Code Here

    try {
      final FormatTextParser parser =  new FormatTextParser() {
        @Override
        public void normalText(final String txt) throws BadLocationException {
          doc.insertString(doc.getLength(), txt, getStyle(color,styleDescription));
        }

        @Override
        public void colorText(final String txt) throws BadLocationException {
          doc.insertString(doc.getLength(), txt, textPane.getStyle("bold"));
View Full Code Here

          doc.insertString(doc.getLength(), txt, getStyle(color,styleDescription));
        }

        @Override
        public void colorText(final String txt) throws BadLocationException {
          doc.insertString(doc.getLength(), txt, textPane.getStyle("bold"));
        }
      };
      parser.format(text);
    } catch (final Exception e) {
      // BadLocationException
View Full Code Here

   * 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

            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

                    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

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.