List of usage examples for javax.swing.text Caret getDot
public int getDot();
From source file:org.domainmath.gui.MainFrame.java
public void deleteText() { RSyntaxTextArea textArea = commandArea; boolean beep = true; if ((textArea != null) && (textArea.isEditable())) { try {/* w w w .j a va2 s . c om*/ Document doc = textArea.getDocument(); Caret caret = textArea.getCaret(); int dot = caret.getDot(); int mark = caret.getMark(); if (dot != mark) { doc.remove(Math.min(dot, mark), Math.abs(dot - mark)); beep = false; } else if (dot < doc.getLength()) { int delChars = 1; if (dot < doc.getLength() - 1) { String dotChars = doc.getText(dot, 2); char c0 = dotChars.charAt(0); char c1 = dotChars.charAt(1); if (c0 >= '\uD800' && c0 <= '\uDBFF' && c1 >= '\uDC00' && c1 <= '\uDFFF') { delChars = 2; } } doc.remove(dot, delChars); beep = false; } } catch (Exception bl) { } } if (beep) { UIManager.getLookAndFeel().provideErrorFeedback(textArea); } textArea.requestFocusInWindow(); }
From source file:org.executequery.gui.editor.autocomplete.QueryEditorAutoCompletePopupProvider.java
public void firePopupTrigger() { try {/*from w w w . j a va 2 s .c om*/ final JTextComponent textComponent = queryEditorTextComponent(); Caret caret = textComponent.getCaret(); final Rectangle caretCoords = textComponent.modelToView(caret.getDot()); addFocusActions(); resetCount = 0; captureAndResetListValues(); popupMenu().show(textComponent, caretCoords.x, caretCoords.y + caretCoords.height); textComponent.requestFocus(); } catch (BadLocationException e) { debug("Error on caret coordinates", e); } }