本文整理了Java中javax.swing.text.JTextComponent.getCaret()
方法的一些代码示例,展示了JTextComponent.getCaret()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.getCaret()
方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:getCaret
暂无
代码示例来源:origin: stackoverflow.com
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
DefaultCaret caret = (DefaultCaret) ta.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
display(kind.activity + HOST + " on port " + PORT);
代码示例来源:origin: stackoverflow.com
final int dot = field.getCaret().getDot();
final int mark = field.getCaret().getMark();
if ( field.isEnabled() && field.isEditable() ) {
SwingUtilities.invokeLater( new Runnable() {
field.getCaret().setDot( dot );
代码示例来源:origin: ron190/jsql-injection
try {
Document doc = target.getDocument();
Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
代码示例来源: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
try {
Document doc = target.getDocument();
Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
代码示例来源:origin: stackoverflow.com
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ta = new JTextArea();
DefaultCaret caret = (DefaultCaret) ta.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
frame.add(new JScrollPane(ta));
代码示例来源:origin: stackoverflow.com
txtDetails = new JTextArea(5, 50);
txtDetails.setEditable(false);
DefaultCaret caret = (DefaultCaret) txtDetails.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
JScrollPane scrollPane = new JScrollPane(txtDetails, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
代码示例来源:origin: stackoverflow.com
DefaultCaret caret = (DefaultCaret) jTextArea.getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
@Override
protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
textComponent.getCaret().moveDot(offset);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-platform
public @Override void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
if (offset >= startOffset) {
super.insertString(fb, offset, string, attr);
}
textComponent.getCaret().setVisible(true); // #116083
}
代码示例来源:origin: org.swinglabs.swingx/swingx-core
protected void paintPromptComponent(Graphics g, JTextComponent txt) {
JTextComponent lbl = getPromptComponent(txt);
SwingUtilities.paintComponent(g, lbl, txt, 0, 0, txt.getWidth(), txt.getHeight());
if (txt.getCaret() != null) {
txt.getCaret().paint(g);
}
}
代码示例来源: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: net.java.abeille/abeille
public static void checkAddEntry() {
JTextComponent c = Utilities.getLastActiveComponent();
if (c != null) {
checkAddEntry(c, c.getCaret().getDot());
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
@Override
public void insert(MutableContext context) throws BadLocationException {
FortranBracketCompletion.INSTANCE.charInserted((BaseDocument) context.getDocument(),
context.getOffset(), context.getComponent().getCaret(), context.getText().charAt(0));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public CompletionTask createTask(int queryType, JTextComponent component) {
if ((queryType & COMPLETION_QUERY_TYPE) != 0) {
final int dot = component.getCaret().getDot();
return new AsyncCompletionTask(new Query(dot), component);
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public CompletionTask createTask(int queryType, JTextComponent component) {
if ((queryType & COMPLETION_QUERY_TYPE) != 0) {
final int dot = component.getCaret().getDot();
return new AsyncCompletionTask(new Query(dot), component);
}
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public boolean expandString(char typedChar, String expandStr, ActionEvent evt)
throws BadLocationException {
if (expandString(expandStr, evt)) {
if (addTypedAcceptor.accept(typedChar)) {
int dotPos = editorUI.getComponent().getCaret().getDot();
editorUI.getDocument().insertString(dotPos, String.valueOf(typedChar), null);
}
return true;
}
return false;
}
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!