Package javax.swing.text

Examples of javax.swing.text.BadLocationException


    }

    public Object addHighlight(final int p0, final int p1)
       throws BadLocationException {
        if (p0 < 0 || p1 < p0 || p1 > getDocumentLength()) {
            throw new BadLocationException("invalid range", 0);
        }
        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()) {
            throw new BadLocationException("invalid range", 0);
        }
        int oldStart = getStartOffset();
        int oldEnd = getEndOffset();
        start = document.createPosition(p0);
        end = document.createPosition(p1);
View Full Code Here

   private final void CheckLocation(int offset) throws BadLocationException
   {
      if (offset >= chars.limit())
      {
         throw new BadLocationException("Max size is " + chars.limit(), offset);
      }
   }
View Full Code Here

            return;
        if(selectingValue)
            return;
        // check offset position
        if (offs < 0 || offs > getLength())
            throw new BadLocationException("Invalid offset - must be >= 0 and <= " + getLength(), offs);

        // construct the resulting string
        String currentText = getText(0, getLength());
        String beforeOffset = currentText.substring(0, offs);
        String afterOffset = currentText.substring(offs, currentText.length());
View Full Code Here

        // ignore no deletion
        if (length == 0)
            return;
        // check positions
        if (offs < 0 || offs > getLength() || length < 0 || (offs + length) > getLength())
            throw new BadLocationException("Invalid parameters.", offs);

        if (hitBackspace) {
            // user hit backspace => move the selection backwards
            // old item keeps being selected
            if (offs > 0) {
View Full Code Here

     * @exception BadLocationException
     */
    public int getLineOfOffset(int offset) throws BadLocationException {
        Document doc = getDocument();
        if (offset < 0) {
            throw new BadLocationException("Can't translate offset to line", -1);
        }
        else if (offset > doc.getLength()) {
            throw new BadLocationException("Can't translate offset to line", doc.getLength() + 1);
        }
        else {
            Element map = getDocument().getDefaultRootElement();
            return map.getElementIndex(offset);
        }
View Full Code Here

     * @exception BadLocationException
     */
    public int getLineStartOffset(int line) throws BadLocationException {
        int lineCount = getLineCount();
        if (line < 0) {
            throw new BadLocationException("Negative line", -1);
        }
        else if (line >= lineCount) {
            throw new BadLocationException("No such line", getDocument().getLength() + 1);
        }
        else {
            Element map = getDocument().getDefaultRootElement();
            Element lineElem = map.getElement(line);
            return lineElem.getStartOffset();
View Full Code Here

     * @exception BadLocationException
     */
    public int getLineEndOffset(int line) throws BadLocationException {
        int lineCount = getLineCount();
        if (line < 0) {
            throw new BadLocationException("Negative line", -1);
        }
        else if (line >= lineCount) {
            throw new BadLocationException("No such line", getDocument().getLength() + 1);
        }
        else {
            Element map = getDocument().getDefaultRootElement();
            Element lineElem = map.getElement(line);
            int endOffset = lineElem.getEndOffset();
View Full Code Here

        }
       
        public MultiLineRun(int start, int end, int delimeterSize) throws BadLocationException {
            if (start > end) {
                String msg = "Start offset is after end: ";
                throw new BadLocationException(msg, start);
            }
            if (delimeterSize < 1) {
                String msg = "Delimiters be at least size 1: " +
                              delimeterSize;
                throw new IllegalArgumentException(msg);
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

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.