Package javax.swing.text

Examples of javax.swing.text.BadLocationException


    }

    final int endPos = offs + len;
    if (endPos > getLength())
    {
      throw new BadLocationException("Document Size invalid", endPos);
    }

    final String orgText = getText(0, getLength());
    final StringBuffer str = new StringBuffer(orgText);
    str.delete(offs, offs + len);
View Full Code Here


   */
  public String getText(final int offset, final int length) throws BadLocationException
  {
    if (offset + length > getLength())
    {
      throw new BadLocationException("Document Size invalid", offset + length);
    }

    if (rootElement.getElementCount() == 0)
    {
      return "";
View Full Code Here

    {
      throw new IllegalArgumentException();
    }
    if (offset < 0 || offset > node.getEndOffset())
    {
      throw new BadLocationException("Offset not valid", offset);
    }

    this.node = node;
    this.fromStart = fromStart;
    this.offset = offset;
View Full Code Here

    private int lineToOffset(int line) throws BadLocationException {
        Document d = getDocument();
        try {
            Element element = d.getDefaultRootElement().getElement(line - 1);
            if (element == null) {
                throw new BadLocationException("line " + line + " does not exist", -line);
            }
            return element.getStartOffset();
        } catch (ArrayIndexOutOfBoundsException aioobe) {
            BadLocationException ble = new BadLocationException("line " + line + " does not exist", -line);
            ble.initCause(aioobe);
            throw ble;
        }
    }
View Full Code Here

    public void insertHTML(final HTMLDocument doc, final int offset,
                           final String html, final int popDepth,
                           final int pushDepth, final HTML.Tag insertTag)
            throws BadLocationException, IOException {
        if (offset > doc.getLength()) {
            throw new BadLocationException("Invalid position", offset);
        }

        ParserCallback htmlReader = doc.getReader(offset, popDepth,
                                                  pushDepth, insertTag);
        StringReader in = new StringReader(html);
View Full Code Here

            throws BadLocationException {
        if (pos < 0) {
            throw new RuntimeException("Position cannot be negative");
        }
        if (pos > doc.getLength()) {
            throw new BadLocationException("Invalid position", pos);
        }
        if (doc.getLength() != 0) {
            Element body = doc.getElement(doc.getDefaultRootElement(),
                                          StyleConstants.NameAttribute,
                                          HTML.Tag.BODY);
View Full Code Here

        }
        return iteratorWordStart;
    }

    private static void throwException(final String s, final int i) throws BadLocationException {
        throw new BadLocationException(s, i);
    }
View Full Code Here

    }

    private int  checkLineCount(final int line) throws BadLocationException {
        int count = getDocument().getDefaultRootElement().getElementCount();
        if (line < 0) {
            throw new BadLocationException("Negative line", line);
        }
        if (line >= count) {
            throw new BadLocationException("No such line", line);
        }
        return count;
    }
View Full Code Here

    public int getLineOfOffset(final int offset) throws BadLocationException {
        Document doc = getDocument();
        int length = doc.getLength();
        if (offset < 0 || offset > length) {
            throw new BadLocationException("Can't translate offset to line",
                    offset);
        }
        readLock(doc);
        int index = 0;
        try {
View Full Code Here

     */
    public static void isPositionValid(final View view, final int pos)
        throws BadLocationException {

        if (pos < view.getStartOffset() || pos > view.getEndOffset()) {
            throw new BadLocationException(pos + " not in range "
                                           + view.getStartOffset() + ","
                                           + view.getEndOffset(), pos);
        }
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.BadLocationException

Copyright © 2018 www.massapicom. 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.