Package javax.swing.text

Examples of javax.swing.text.BadLocationException


                      throws BadLocationException {

    Document doc = textArea.getDocument();
    Element line = getLineElem(doc, offs);
    if (line == null) {
      throw new BadLocationException("No word at " + offs, offs);
    }

    int lineStart = line.getStartOffset();
    if (offs==lineStart) { // Start of the line.
      return offs;
View Full Code Here


  private void checkOffsetArgument(int offset) throws BadLocationException {
    if (accessorKey == null)
      return;

    if (offset < 0 || offset > accessor.get(accessorKey).length())
      throw (new BadLocationException("Bad offset in StringDocument",
          offset));
  }
View Full Code Here

    if (accessorKey == null)
      return;

    if (offset < 0 || offset > accessor.get(accessorKey).length())
      throw (new BadLocationException(
          "Bad start location in StringDocument", offset));

    if (length < 0 || offset + length > accessor.get(accessorKey).length())
      throw (new BadLocationException(
          "Bad length argument in StringDocument", offset + length));
  }
View Full Code Here

    RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();

    // Ensure p0 and p1 are valid document positions.
    if (p0<0)
      throw new BadLocationException("Invalid document position", p0);
    else if (p1>doc.getLength())
      throw new BadLocationException("Invalid document position", p1);

    // Ensure p0 and p1 are in the same line, and get the start/end
    // offsets for that line.
    Element map = doc.getDefaultRootElement();
    int lineNum = map.getElementIndex(p0);
View Full Code Here

                      throws BadLocationException {

    Document doc = textArea.getDocument();
    Element line = getLineElem(doc, offs);
    if (line == null) {
      throw new BadLocationException("No word at " + offs, offs);
    }

    int lineStart = line.getStartOffset();
    if (offs==lineStart) { // Start of the line.
      return offs;
View Full Code Here

    {
      fb.replace(offset, length, str, attrs);
    }
    else
    {
      throw new BadLocationException("New characters exceeds max size of document", offset);
    }
  }
View Full Code Here

    public Object addHighlight(final int p0, final int p1)
       throws BadLocationException {
        if (p0 < 0 || p1 < p0 || p1 > getDocumentLength()) {
            // awt.29=Invalid range
            throw new BadLocationException(Messages.getString("awt.29"), 0); //$NON-NLS-1$
        }
        start = document.createPosition(p0);
        end = document.createPosition(p1);
        repaintComponent(TextUtils.getBoundsByOffsets(textKit, p0, p1));
        return Boolean.TRUE;
View Full Code Here

    public void changeHighlight(final int p0, final int p1)
       throws BadLocationException {
        if (p0 < 0 || p1 < p0 || p1 > getDocumentLength()) {
            // awt.29=Invalid range
            throw new BadLocationException(Messages.getString("awt.29"), 0); //$NON-NLS-1$
        }
        int oldStart = getStartOffset();
        int oldEnd = getEndOffset();
        start = document.createPosition(p0);
        end = document.createPosition(p1);
View Full Code Here

        }
    }

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

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

        if (pos < view.getStartOffset() || pos > view.getEndOffset()) {
            // awt.2E={0} not in range {1},{2}
            throw new BadLocationException(Messages.getString("awt.2E", //$NON-NLS-1$
                    new Object[] { pos, 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.