use of javax.swing.text.BadLocationException in project antlrworks by antlr.
the class EditorTips method display.
public void display(Point relativePoint, Point absolutePoint) {
if (window.getTokens() == null)
return;
int position = window.getTextPane().viewToModel(relativePoint);
Point p = null;
try {
ATEToken token = window.getTokenAtPosition(position, false);
if (token != null) {
// Make sure the mouse is over the token because
// Swing will return a valid position even if the mouse
// is on the remaining blank part of the line
Rectangle r1 = window.getTextPane().modelToView(token.getStartIndex());
Rectangle r2 = window.getTextPane().modelToView(token.getEndIndex());
if (r1.union(r2).contains(relativePoint)) {
p = SwingUtilities.convertPoint(window.getTextPane(), new Point(relativePoint.x + 2, r2.y - 5), window.getJavaContainer());
}
}
} catch (BadLocationException e) {
// Ignore
}
tipsManager.displayAnyTipsAvailable(position, p);
}
use of javax.swing.text.BadLocationException in project groovy by apache.
the class LexerFrame method actionPerformed.
public void actionPerformed(ActionEvent ae) {
Token token = (Token) ((JComponent) ae.getSource()).getClientProperty("token");
if (token.getType() == Token.EOF_TYPE) {
scriptPane.select(0, 0);
return;
}
try {
int start = scriptPane.getLineStartOffset(token.getLine() - 1) + token.getColumn() - 1;
scriptPane.select(start, start + token.getText().length());
scriptPane.requestFocus();
} catch (BadLocationException ex) {
// IGNORE
}
}
use of javax.swing.text.BadLocationException in project LogisticsPipes by RS485.
the class LogWindow method newLine.
public void newLine(String data) {
SimpleAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontFamily(attr, "SansSerif");
StyleConstants.setFontSize(attr, 12);
// StyleConstants.setForeground(attr, color);
Document document = logArea.getDocument();
if (document != null) {
try {
document.insertString(document.getLength(), data + "\n", attr);
} catch (BadLocationException badlocationexception) {
}
}
validate();
}
use of javax.swing.text.BadLocationException in project LogisticsPipes by RS485.
the class DebugWindow method showInfo.
public void showInfo(String data, Color color) {
SimpleAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontFamily(attr, "SansSerif");
StyleConstants.setFontSize(attr, 12);
StyleConstants.setForeground(attr, color);
Document document = textArea.getDocument();
if (document != null) {
try {
document.insertString(document.getLength(), data, attr);
} catch (BadLocationException badlocationexception) {
}
}
getContentPane().validate();
}
use of javax.swing.text.BadLocationException in project SKMCLauncher by SKCraft.
the class LimitLinesDocumentListener method removeFromEnd.
private void removeFromEnd(Document document, Element root) {
// We use start minus 1 to make sure we remove the newline
// character of the previous line
Element line = root.getElement(root.getElementCount() - 1);
int start = line.getStartOffset();
int end = line.getEndOffset();
try {
document.remove(start - 1, end - start);
} catch (BadLocationException ble) {
System.out.println(ble);
}
}
Aggregations