本文整理了Java中javax.swing.text.BadLocationException.getMessage()
方法的一些代码示例,展示了BadLocationException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BadLocationException.getMessage()
方法的具体详情如下:
包路径:javax.swing.text.BadLocationException
类名称:BadLocationException
方法名:getMessage
暂无
代码示例来源:origin: groovy/groovy-core
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
// starting position in document
int start = textEditor.viewToModel(getViewport().getViewPosition());
// end position in document
int end = textEditor.viewToModel(new Point(10,
getViewport().getViewPosition().y +
(int) textEditor.getVisibleRect().getHeight())
);
// translate offsets to lines
Document doc = textEditor.getDocument();
int startline = doc.getDefaultRootElement().getElementIndex(start) + 1;
int endline = doc.getDefaultRootElement().getElementIndex(end) + 1;
Font f = textEditor.getFont();
int fontHeight = g.getFontMetrics(f).getHeight();
int fontDesc = g.getFontMetrics(f).getDescent();
int startingY = -1;
try {
startingY = textEditor.modelToView(start).y + fontHeight - fontDesc;
} catch (BadLocationException e1) {
System.err.println(e1.getMessage());
}
g.setFont(f);
for (int line = startline, y = startingY; line <= endline; y += fontHeight, line++) {
String lineNumber = StringGroovyMethods.padLeft(Integer.toString(line), 4, " ");
g.drawString(lineNumber, 0, y);
}
}
}
代码示例来源:origin: pmd/pmd
@Override
public void run() {
try {
sourceCodeArea.getHighlighter().removeAllHighlights();
if (node == null) {
return;
}
int startOffset = sourceCodeArea.getLineStartOffset(node.getBeginLine() - 1)
+ node.getBeginColumn() - 1;
int end = sourceCodeArea.getLineStartOffset(node.getEndLine() - 1) + node.getEndColumn();
sourceCodeArea.getHighlighter().addHighlight(startOffset, end,
new DefaultHighlighter.DefaultHighlightPainter(HIGHLIGHT_COLOR));
sourceCodeArea.moveCaretPosition(startOffset);
} catch (BadLocationException exc) {
throw new IllegalStateException(exc.getMessage());
}
}
});
代码示例来源:origin: ron190/jsql-injection
/**
* Add a text at the end of textpane.
* @param string Text to add
*/
public void append(String string) {
try {
Document doc = this.getDocument();
doc.insertString(doc.getLength(), string, null);
} catch (BadLocationException e) {
LOGGER.error(e.getMessage(), e);
}
}
代码示例来源:origin: ron190/jsql-injection
public void append(JTextPane l, String text) {
try {
l.getDocument().insertString(
l.getDocument().getLength(),
(l.getDocument().getLength() == 0 ? "" : "\n") + text,
null
);
} catch (BadLocationException e) {
LOGGER.error(e.getMessage(), e);
}
}
代码示例来源:origin: ron190/jsql-injection
/**
* Add a colored string to the textpane, measure prompt at the same time.
* @param string Text to append
* @param color Color of text
* @param isAddingPrompt Should we measure prompt length?
*/
private void appendPrompt(String string, Color color, boolean isAddingPrompt) {
try {
StyleConstants.setForeground(this.style, color);
this.styledDocument.insertString(this.styledDocument.getLength(), string, this.style);
if (isAddingPrompt) {
this.prompt += string;
}
} catch (BadLocationException e) {
LOGGER.error(e.getMessage(), e);
}
}
代码示例来源:origin: ron190/jsql-injection
LOGGER.error(e.getMessage(), e);
return;
代码示例来源:origin: bobbylight/RSyntaxTextArea
str, null);
} catch (BadLocationException e) {
throw new IllegalArgumentException(e.getMessage());
} finally {
undoManager.endInternalAtomicEdit();
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* We override this method because the super version gives us an entirely
* new <code>Document</code>, thus requiring us to re-attach our Undo
* manager. With this version we just replace the text.
*/
@Override
public void read(Reader in, Object desc) throws IOException {
RTextAreaEditorKit kit = (RTextAreaEditorKit)getUI().getEditorKit(this);
setText(null);
Document doc = getDocument();
if (desc != null) {
doc.putProperty(Document.StreamDescriptionProperty, desc);
}
try {
// NOTE: Resets the "line separator" property.
kit.read(in, doc, 0);
} catch (BadLocationException e) {
throw new IOException(e.getMessage());
}
}
代码示例来源:origin: ron190/jsql-injection
LOGGER.error(e.getMessage(), e);
代码示例来源:origin: stackoverflow.com
if (evt.getKeyCode() == 10) {
try {
int offset=ta.getLineOfOffset(ta.getCaretPosition());
int start=ta.getLineStartOffset(offset);
int end=ta.getLineEndOffset(offset);
System.out.println("Text: "+ta.getText(start, (end-start)));
} catch (BadLocationException ex) {
System.out.println(ex.getMessage());
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document
public static Position createPosition(Document doc, int offset) {
try {
return doc.createPosition(offset);
} catch (BadLocationException ex) {
throw new IndexOutOfBoundsException(ex.getMessage());
}
}
代码示例来源:origin: apache/ctakes
@Override
public void actionPerformed( final ActionEvent event ) {
try {
final int caret = getInsertCaret();
_piperDocument.insertString( caret, "\n// Load a Piper file containing a partial Pipeline\nload ", null );
} catch ( BadLocationException blE ) {
LOGGER.error( blE.getMessage() );
}
_runButton.setEnabled( false );
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
void addBlockFoldInfo(CppFoldRecord foldRecord) {
if (foldRecord != null) {
try {
blockFoldInfos.add(new BlockFoldInfo(foldRecord));
} catch (BadLocationException ex) {
if (log.isLoggable(Level.FINE)){
log.log(Level.FINE, "CFM.addBlockFoldInfo: Got BadLocationException\n {0}", // NOI18N
ex.getMessage());
}
}
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl
private IOException convert(BadLocationException e) {
IOException ioe = new IOException(e.getMessage());
ioe.setStackTrace(e.getStackTrace());
return ioe;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl
private IOException toIOException(BadLocationException e) {
IOException ioe = new IOException(e.getMessage());
ioe.setStackTrace(e.getStackTrace());
return ioe;
}
代码示例来源:origin: otros-systems/otroslogviewer
private void scrollToSearchResult(ArrayList<String> toHighlight, JTextPane textPane) {
if (toHighlight.size() == 0) {
return;
}
try {
StyledDocument logDetailsDocument = textPane.getStyledDocument();
String text = logDetailsDocument.getText(0, logDetailsDocument.getLength());
String string = toHighlight.get(0);
textPane.setCaretPosition(Math.max(text.indexOf(string), 0));
} catch (BadLocationException e) {
LOGGER.warn("Cant scroll to content, wrong location: " + e.getMessage());
}
}
代码示例来源:origin: org.zaproxy/zap
public Object highlight(int start, int end, HighlightPainter painter) {
try {
Object highlightReference = getHighlighter().addHighlight(start, end, painter);
this.setCaretPosition(start);
return highlightReference;
} catch (BadLocationException e) {
log.error(e.getMessage(), e);
}
return null;
}
代码示例来源:origin: UISpec4J/UISpec4J
public void clear() {
UISpecAssert.assertTrue(isEditable());
Document document = jTextComponent.getDocument();
try {
document.remove(0, document.getLength());
}
catch (BadLocationException e) {
AssertAdapter.fail("Clear failed: " + e.getMessage());
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mylyn-util
private void makeCaretVisible(JTextComponent textComponent) {
int pos = textComponent.getCaretPosition();
try {
Rectangle rec = textComponent.getUI().modelToView(textComponent, pos);
if (rec != null) {
Point p = SwingUtilities.convertPoint(textComponent, rec.x, rec.y, this);
scrollRectToVisible(new Rectangle(p.x, p.y, rec.width, rec.height));
}
} catch (BadLocationException blex) {
LOG.log(Level.INFO, blex.getMessage(), blex);
}
}
代码示例来源:origin: org.zaproxy/zap
protected void highlight(int start, int end) {
Highlighter hilite = this.getHighlighter();
HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.LIGHT_GRAY);
try {
// DOBIN
removeAllHighlights();
hilite.addHighlight(start, end, painter);
this.setCaretPosition(start);
} catch (BadLocationException e) {
log.error(e.getMessage(), e);
}
}
内容来源于网络,如有侵权,请联系作者删除!