本文整理了Java中javax.swing.text.Caret.setDot()
方法的一些代码示例,展示了Caret.setDot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Caret.setDot()
方法的具体详情如下:
包路径:javax.swing.text.Caret
类名称:Caret
方法名:setDot
暂无
代码示例来源:origin: stackoverflow.com
field.getCaret().setDot( dot );
代码示例来源: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
int mark = caret.getMark();
if (dot!=mark) {
caret.setDot(Math.max(dot, mark));
return;
mark = caret.getMark();
if (dot!=mark) {
caret.setDot(Math.min(dot, mark));
return;
caret.setDot(dot);
代码示例来源: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: org.apache.uima/uimaj-tools
/**
* Sets the text no title.
*
* @param text the new text no title
*/
// Set the text.
public void setTextNoTitle(String text) {
this.textArea.setText(text);
this.textArea.getCaret().setDot(0);
this.isDirty = false;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-railsprojects
private void showUsage(Generator generator) {
// Look up the Rails directory and read the USAGE file, then stick
// it into the usageText.
String usage = generator.getUsage(project);
if (usage != null) {
usageText.setText(usage);
usageText.getCaret().setDot(0);
} else {
usageText.setText("");
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-core
public void run() {
// XXX #28191: some other piece of code should underline these, etc.
StringWriter wr = new StringWriter();
current.printStackTrace(new PrintWriter(wr, true));
output.setText(wr.toString());
output.getCaret().setDot(0);
output.requestFocus ();
}
});
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
Caret caret = target.getCaret();
int dot = 0; // begin of document
if (select) {
caret.moveDot(dot);
} else {
caret.setDot(dot);
}
}
}
}
代码示例来源:origin: net.java.abeille/abeille
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
Caret caret = target.getCaret();
int dot = 0; // begin of document
if (select) {
caret.moveDot(dot);
}
else {
caret.setDot(dot);
}
}
}
}
代码示例来源:origin: net.java.abeille/abeille
public boolean substituteText(JTextComponent c, int a, int b, boolean shift) {
replaceText(c, "<" + baseText + (shift ? " >" : ">")); // NOI18N
if (shift) {
Caret caret = c.getCaret();
caret.setDot(caret.getDot() - 1);
}
return !shift; // flag == false;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public boolean substituteText( JTextComponent c, int a, int b, boolean shift ) {
replaceText( c, baseText + "=\"\"" ); //NOI18N
if( shift ) {
Caret caret = c.getCaret();
caret.setDot( caret.getDot() - 1 );
}
return false; // always refresh
}
}
代码示例来源:origin: com.eas.platypus/platypus-js-calendar-widget
@Override
public void remove(int offs, int len) throws BadLocationException {
super.remove(offs, len);
dEditor.getTextField().getCaret().setDot(offs);
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-extension-openide
/**
* called to restore the state of a component
* because a drop was not performed.
*/
protected void restoreComponentState(JComponent comp) {
JTextComponent c = (JTextComponent) comp;
Caret caret = c.getCaret();
caret.setDot(mark);
caret.moveDot(dot);
caret.setVisible(visible);
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
public static void selectLineAtCaret( JTextComponent editor )
{
int lineStart = getLineStart( editor.getText(), editor.getCaretPosition() );
int lineEnd = getLineEnd( editor.getText(), editor.getCaretPosition() );
if( lineEnd < editor.getText().length() )
{
lineEnd++;
}
editor.getCaret().setDot( lineEnd );
editor.getCaret().moveDot( lineStart );
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
@Override
public void afterInsert(Context context) throws BadLocationException {
if (postShift) {
Caret caret = context.getComponent().getCaret();
caret.setDot(context.getCaretOffset() + 1);
}
}
代码示例来源:origin: JGillam/burp-paramalyzer
@Override
public void actionPerformed(ActionEvent e) {
ParamInstance pi = paramListModel.getParamInstance(listValues.getSelectedIndex());
if (pi != null) {
Caret caret = textAreaRequest.getCaret();
caret.setSelectionVisible(true);
caret.setDot(pi.getValueStart());
caret.moveDot(pi.getValueEnd());
}
}
});
代码示例来源:origin: org.jenkins-ci/executable-war
/**
* Forces the scroll of text area.
*/
private void scrollDown() {
int pos = textArea.getDocument().getEndPosition().getOffset();
textArea.getCaret().setDot(pos);
textArea.requestFocus();
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
private void select(SelectionInfo selectionInfo) {
Caret caret = target.getCaret();
markIgnoreNextCaretUpdate();
caret.setDot(selectionInfo.getStartOffset());
markIgnoreNextCaretUpdate();
caret.moveDot(selectionInfo.getEndOffset());
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf
private void select(SelectionInfo selectionInfo) {
Caret caret = target.getCaret();
markIgnoreNextCaretUpdate();
caret.setDot(selectionInfo.getStartOffset());
markIgnoreNextCaretUpdate();
caret.moveDot(selectionInfo.getEndOffset());
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
private void setSelection( Point point )
{
Rectangle visibleRect = _gsEditor.getEditor().getVisibleRect();
_gsEditor.getEditor().getCaret().setDot( point.x );
_gsEditor.getEditor().getCaret().moveDot( point.y );
_gsEditor.getEditor().scrollRectToVisible( visibleRect );
}
内容来源于网络,如有侵权,请联系作者删除!