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

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

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

BadLocationException.toString介绍

暂无

代码示例

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * {@inheritDoc}
 */
@Override
public char charAt(int index) {
  if (index<0 || index>=length()) {
    throw new IndexOutOfBoundsException("Index " + index +
        " is not in range [0-" + length() + ")");
  }
  try {
    return doc.charAt(start+index);
  } catch (BadLocationException ble) {
    throw new IndexOutOfBoundsException(ble.toString());
  }
}

代码示例来源:origin: stackoverflow.com

ActionListener listener = new ActionListener() {

  @Override
  public void actionPerformed(ActionEvent ae) {

    int pos = area.getCaretPosition();
    try {
      Rectangle r = area.modelToView(pos);
      menu.show(area, r.x, r.y);
    } catch (BadLocationException ex) {
      System.out.print(ex.toString());
    }

  }
};

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-insync

/** Document itself is encoded as Unicode, but in
* the document prolog is an encoding attribute.
* @return java encoding names ("UTF8", "ASCII", etc.) or null if no guess
*/
public static String detectEncoding(Document doc) throws IOException {
  if (doc == null) return null;
  try {
    String text = doc.getText(0,
                 doc.getLength() > EXPECTED_PROLOG_LENGTH ?
                 EXPECTED_PROLOG_LENGTH : doc.getLength()
                 );
    InputStream in = new ByteArrayInputStream(text.getBytes());
    return detectEncoding(in);
  } catch (BadLocationException ex) {
    throw new RuntimeException(ex.toString());
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * Sets the text of this AutoCompleteDocument to the given text.
 *
 * @param text the text that will be set for this document
 */
private void setText(String text) {
  try {
    // remove all text and insert the completed string
    delegate.remove(0, getLength());
    delegate.insertString(0, text, null);
  } catch (BadLocationException e) {
    throw new RuntimeException(e.toString());
  }
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

/**
 * Sets the text of this AutoCompleteDocument to the given text.
 * 
 * @param text the text that will be set for this document
 */
private void setText(String text) {
  try {
    // remove all text and insert the completed string
    delegate.remove(0, getLength());
    delegate.insertString(0, text, null);
  } catch (BadLocationException e) {
    throw new RuntimeException(e.toString());
  }
}

代码示例来源:origin: tmyroadctfig/swingx

/**
 * Sets the text of this AutoCompleteDocument to the given text.
 *
 * @param text the text that will be set for this document
 */
private void setText(String text) {
  try {
    // remove all text and insert the completed string
    delegate.remove(0, getLength());
    delegate.insertString(0, text, null);
  } catch (BadLocationException e) {
    throw new RuntimeException(e.toString());
  }
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

throw new IOException(ble.toString());

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

private void caretUpdate(javax.swing.event.CaretEvent evt) {
  try {
    int pos = editor.getCaretPosition();
    int line = getLineOfOffset(pos);
    int lineStartOffset = getLineStartOffset(line);
    caretInfoLabel.setText((line + 1) + ":" + (pos - lineStartOffset + 1));
  } catch (BadLocationException e) {
    caretInfoLabel.setText(e.toString());
  }
}

代码示例来源:origin: triplea-game/triplea

private void setText(final String text) {
 try {
  // remove all text and insert the completed string
  super.remove(0, getLength());
  super.insertString(0, text, null);
 } catch (final BadLocationException e) {
  throw new RuntimeException(e.toString());
 }
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

/**
 * {@inheritDoc}
 */
@Override
public char charAt(int index) {
  if (index<0 || index>=length()) {
    throw new IndexOutOfBoundsException("Index " + index +
        " is not in range [0-" + length() + ")");
  }
  try {
    return doc.charAt(start+index);
  } catch (BadLocationException ble) {
    throw new IndexOutOfBoundsException(ble.toString());
  }
}

代码示例来源:origin: T145/JTerm

void protect(int start, int end) {
  try {
    positions.put(doc.createPosition(start), doc.createPosition(end));
  } catch (BadLocationException ble) {
    JTerm.out.println(TextColor.ERROR, ble.toString());
  }
}

代码示例来源:origin: net.sf.cuf/cuf-swing

private void setText(final String pText)
{
  try
  {
    // remove all text and insert the completed string
    super.remove(0, getLength());
    super.insertString(0, pText, null);
  }
  catch (BadLocationException e)
  {
    throw new RuntimeException(e.toString());
  }
}

代码示例来源:origin: blurpy/kouchat

@Override
  public void run() {
    try {
      StyleConstants.setForeground(chatAttr, new Color(color));
      chatDoc.insertString(chatDoc.getLength(), message + "\n", chatAttr);
      chatTP.setCaretPosition(chatDoc.getLength());
    }
    catch (final BadLocationException e) {
      LOG.log(Level.SEVERE, e.toString(), e);
    }
  }
});

代码示例来源:origin: blurpy/kouchat

/**
 * Shows the window if the text file was opened, and scrolls to the
 * beginning of the text.
 *
 * {@inheritDoc}
 */
@Override
public void setVisible(final boolean visible) {
  if (fileOpened) {
    if (visible) {
      try {
        final Rectangle r = viewerTP.modelToView(0);
        viewerScroll.getViewport().setViewPosition(new Point(r.x, r.y));
      }
      catch (final BadLocationException e) {
        LOG.log(Level.SEVERE, e.toString());
      }
    }
    super.setVisible(visible);
  }
  else {
    errorHandler.showError(swingMessages.getMessage("swing.textViewerDialog.errorPopup.openFile", textFile));
  }
}

代码示例来源:origin: blurpy/kouchat

@Override
  public void run() {
    try {
      StyleConstants.setForeground(chatAttr, new Color(color));
      chatDoc.insertString(chatDoc.getLength(), message + "\n", chatAttr);
      chatTP.setCaretPosition(chatDoc.getLength());
    }
    catch (final BadLocationException e) {
      LOG.log(Level.SEVERE, e.toString(), e);
    }
  }
});

代码示例来源:origin: cytoscape.coreplugins/quickfind

/**
 * Sets Document Text.
 *
 * @param text Document Text.
 */
private void setText(String text) {
  debug("setText(), text=" + text);
  try {
    // remove all text and insert the completed string
    super.remove(0, getLength());
    super.insertString(0, text, null);
  } catch (BadLocationException e) {
    throw new RuntimeException(e.toString());
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

protected void setText(String text) {
    try {
      // remove all text and insert the completed string
      if (isStrictCompletion()) {
        super.remove(0, getLength());
        super.insertString(0, text, null);
      }
      else {
        String existingText = super.getText(0, getLength());
        int matchIndex = existingText.length() <= text.length() ? existingText.length() : text.length();
        // try to find a match
        for (int i = 0; i < existingText.length(); i++) {
          if (!existingText.substring(0, matchIndex).equalsIgnoreCase(text.substring(0, matchIndex))) {
            matchIndex--;
          }
        }
        // remove the no-match part and complete with the one in Searchable
        super.remove(matchIndex, getLength() - matchIndex);
        super.insertString(matchIndex, text.substring(matchIndex), null);
      }
    }
    catch (BadLocationException e) {
      throw new RuntimeException(e.toString());
    }
  }
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

throw new AWTError(ble.toString());

代码示例来源:origin: jpos/jPOS

public void run () {
  if (ui.isDestroyed ()) {
    logger.removeListener (this);
    text.setText ("");
    return;
  }
  int lc = text.getLineCount ();
  if (lc > maxLines) {
    try {
      int startOffset = text.getLineStartOffset (maxLines);
      int endOffset = text.getLineEndOffset(lc-1);
      text.getDocument ().remove (startOffset, endOffset-startOffset);
    } catch (BadLocationException ex) {
      text.setText (ex.toString());
    }
  }
}
public LogEvent log (LogEvent evt) {

代码示例来源:origin: JGillam/burp-co2

@Override
public void keyReleased(KeyEvent e) {
  if (e.getKeyCode() == KeyEvent.VK_ENTER) {
    int currentPosition = txtConsole.getCaretPosition();
    try {
      String command = txtConsole.getText(commandStart, (currentPosition - commandStart - 1));
      runCommand(command, false);
    } catch (BadLocationException e1) {
      callbacks.printError(e1.toString());
    } catch (MalformedURLException e1) {
      callbacks.printError(e1.toString());
    } catch (NumberFormatException e1) {
      callbacks.printError(e1.toString());
    }
  } else {
    super.keyReleased(e);
  }
}

相关文章