javax.swing.text.BadLocationException.initCause()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中javax.swing.text.BadLocationException.initCause()方法的一些代码示例,展示了BadLocationException.initCause()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BadLocationException.initCause()方法的具体详情如下:
包路径:javax.swing.text.BadLocationException
类名称:BadLocationException
方法名:initCause

BadLocationException.initCause介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

private static BadLocationException getBadLocationException(IndexOutOfBoundsException ex, String text, int offset) {
  BadLocationException ble = new BadLocationException(offset + " out of " + text.length(), offset);
  ble.initCause(ex);
  return ble;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans

static int getRowFirstNonWhite(StyledDocument doc, int offset)
    throws BadLocationException {
  Element lineElement = doc.getParagraphElement(offset);
  int start = lineElement.getStartOffset();
  while (start + 1 < lineElement.getEndOffset()) {
    try {
      if (doc.getText(start, 1).charAt(0) != ' ') {
        break;
      }
    } catch (BadLocationException ex) {
      throw (BadLocationException) new BadLocationException(
          "calling getText(" + start + ", " + (start + 1)
          + ") on doc of length: " + doc.getLength(), start).initCause(ex);
    }
    start++;
  }
  return start;
}

代码示例来源:origin: com.google.code.findbugs/findbugs

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;
  }
}

相关文章