本文整理了Java中javax.swing.text.Caret.getDot()
方法的一些代码示例,展示了Caret.getDot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Caret.getDot()
方法的具体详情如下:
包路径:javax.swing.text.Caret
类名称:Caret
方法名:getDot
暂无
代码示例来源:origin: JetBrains/ideavim
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent e) {
ExTextField target = (ExTextField)getTextComponent(e);
target.saveLastEntry();
Document doc = target.getDocument();
Caret caret = target.getCaret();
try {
doc.remove(caret.getDot(), doc.getLength());
}
catch (BadLocationException ex) {
// ignore
}
}
}
代码示例来源:origin: JetBrains/ideavim
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent e) {
ExTextField target = (ExTextField)getTextComponent(e);
target.saveLastEntry();
Document doc = target.getDocument();
Caret caret = target.getCaret();
int offset = SearchHelper.findNextWord(target.getText(), caret.getDot(), target.getText().length(),
-1, false, false);
if (logger.isDebugEnabled()) logger.debug("offset=" + offset);
try {
int pos = caret.getDot();
doc.remove(offset, pos - offset);
}
catch (BadLocationException ex) {
// ignore
}
}
}
代码示例来源:origin: JetBrains/ideavim
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent e) {
ExTextField target = (ExTextField)getTextComponent(e);
target.saveLastEntry();
Document doc = target.getDocument();
Caret caret = target.getCaret();
try {
doc.remove(0, caret.getDot());
}
catch (BadLocationException ex) {
// ignore
}
}
}
代码示例来源:origin: JetBrains/ideavim
Document doc = target.getDocument();
Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
代码示例来源:origin: stackoverflow.com
final int dot = field.getCaret().getDot();
final int mark = field.getCaret().getMark();
if ( field.isEnabled() && field.isEditable() ) {
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Makes the caret's dot and mark the same location so that, for the
* next search in the specified direction, a match will be found even
* if it was within the original dot and mark's selection.
*
* @param textArea The text area.
* @param forward Whether the search will be forward through the
* document (<code>false</code> means backward).
* @return The new dot and mark position.
*/
private static int makeMarkAndDotEqual(JTextArea textArea,
boolean forward) {
Caret c = textArea.getCaret();
int val = forward ? Math.min(c.getDot(), c.getMark()) :
Math.max(c.getDot(), c.getMark());
c.setDot(val);
return val;
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
@Override
public void mouseDragged(MouseEvent e) {
// WORKAROUND: Since JTextComponent only updates the caret
// location on mouse clicked and released, we'll do it on dragged
// events when the left mouse button is clicked.
if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
Caret caret = getCaret();
dot = caret.getDot();
mark = caret.getMark();
fireCaretUpdate(this);
}
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
@Override
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) { // OS X popup triggers are on pressed
showPopup(e);
}
else if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
Caret caret = getCaret();
dot = caret.getDot();
mark = caret.getMark();
fireCaretUpdate(this);
}
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void actionPerformed(ActionEvent e) {
JTextComponent target = this.getTextComponent(e);
if (Objects.nonNull(target) && target.isEditable()) {
Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (DefaultEditorKit.deletePrevCharAction.equals(this.getValue(Action.NAME))) {
// @see javax/swing/text/DefaultEditorKit.java DeletePrevCharAction
if (dot == 0 && mark == 0) {
return;
}
} else {
// @see javax/swing/text/DefaultEditorKit.java DeleteNextCharAction
Document doc = target.getDocument();
if (dot == mark && doc.getLength() == dot) {
return;
}
}
}
this.deleteAction.actionPerformed(e);
}
代码示例来源:origin: ron190/jsql-injection
Document doc = target.getDocument();
Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
代码示例来源:origin: ron190/jsql-injection
Document doc = target.getDocument();
Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
代码示例来源:origin: bobbylight/RSyntaxTextArea
Document doc = textArea.getDocument();
Caret caret = textArea.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
代码示例来源:origin: bobbylight/RSyntaxTextArea
Document doc = textArea.getDocument();
Caret caret = textArea.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
代码示例来源:origin: bobbylight/RSyntaxTextArea
if (caret.getDot()==caret.getMark()) {
代码示例来源:origin: bobbylight/RSyntaxTextArea
@Override
public void focusGained(FocusEvent e) {
Caret c = getCaret();
boolean enabled = c.getDot()!=c.getMark();
cutAction.setEnabled(enabled);
copyAction.setEnabled(enabled);
undoManager.updateActions(); // To reflect this text area.
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Sets whether the edges of selections are rounded in this text area.
* This method fires a property change of type
* {@link #ROUNDED_SELECTION_PROPERTY}.
*
* @param rounded Whether selection edges should be rounded.
* @see #getRoundedSelectionEdges()
*/
public void setRoundedSelectionEdges(boolean rounded) {
if (roundedSelectionEdges!=rounded) {
roundedSelectionEdges = rounded;
Caret c = getCaret();
if (c instanceof ConfigurableCaret) {
((ConfigurableCaret)c).setRoundedSelectionEdges(rounded);
if (c.getDot()!=c.getMark()) { // e.g., there's is a selection
repaint();
}
}
firePropertyChange(ROUNDED_SELECTION_PROPERTY, !rounded,
rounded);
}
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
int dot = c.getDot();
int mark = c.getMark();
int p0 = Math.min(dot, mark);
代码示例来源:origin: bobbylight/RSyntaxTextArea
boolean selection = c.getDot()!=c.getMark();
rsta.replaceSelection("/");
int dot = c.getDot();
代码示例来源:origin: bobbylight/RSyntaxTextArea
@Override
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
if (!textArea.isEditable() || !textArea.isEnabled()) {
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
return;
}
try {
Caret c = textArea.getCaret();
int caretPos = c.getDot();
Document doc = textArea.getDocument();
Element map = doc.getDefaultRootElement();
int lineCount = map.getElementCount();
int line = map.getElementIndex(caretPos);
if (line==lineCount-1) {
UIManager.getLookAndFeel().
provideErrorFeedback(textArea);
return;
}
Element lineElem = map.getElement(line);
caretPos = lineElem.getEndOffset() - 1;
c.setDot(caretPos); // Gets rid of any selection.
doc.remove(caretPos, 1); // Should be '\n'.
} catch (BadLocationException ble) {
/* Shouldn't ever happen. */
ble.printStackTrace();
}
textArea.requestFocusInWindow();
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* {@inheritDoc}
*/
@Override
public Token getTokenToMark(RSyntaxTextArea textArea) {
// Get the token at the caret position.
int line = textArea.getCaretLineNumber();
Token tokenList = textArea.getTokenListForLine(line);
Caret c = textArea.getCaret();
int dot = c.getDot();
Token t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot);
if (t==null /* EOL */ || !isValidType(textArea, t) ||
RSyntaxUtilities.isNonWordChar(t)) {
// Try to the "left" of the caret.
dot--;
try {
if (dot>=textArea.getLineStartOffset(line)) {
t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot);
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
}
}
return t;
}
内容来源于网络,如有侵权,请联系作者删除!