本文整理了Java中javax.swing.text.JTextComponent.getSelectionEnd()
方法的一些代码示例,展示了JTextComponent.getSelectionEnd()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.getSelectionEnd()
方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:getSelectionEnd
暂无
代码示例来源:origin: runelite/runelite
private boolean isExpectedNext(JTextComponent input, String nextChar)
{
String expected;
if (input.getSelectionStart() < input.getSelectionEnd())
{
try
{
expected = input.getText(input.getSelectionStart(), 1);
}
catch (BadLocationException ex)
{
log.warn("Could not get first character from input selection.", ex);
return false;
}
}
else
{
expected = "";
}
return nextChar.equalsIgnoreCase(expected);
}
}
代码示例来源:origin: runelite/runelite
if (input.getSelectionEnd() != inputText.length())
doc.remove(insertIndex, 1);
doc.insertString(insertIndex, charToInsert, null);
input.select(insertIndex + 1, input.getSelectionEnd());
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Create a Transferable to use as the source for a data transfer.
*
* @param comp The component holding the data to be transfered. This
* argument is provided to enable sharing of TransferHandlers by
* multiple components.
* @return The representation of the data to be transfered.
*
*/
@Override
protected Transferable createTransferable(JComponent comp) {
exportComp = (JTextComponent)comp;
shouldRemove = true;
p0 = exportComp.getSelectionStart();
p1 = exportComp.getSelectionEnd();
return (p0 != p1) ? (new TextTransferable(exportComp, p0, p1)) : null;
}
代码示例来源:origin: stackoverflow.com
ta.replaceRange("", ta.getSelectionStart(), ta.getSelectionEnd());
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-editor
protected int getSelectionEndLine(final JTextComponent c) {
if (c == null || !(c.getDocument() instanceof StyledDocument)) return 0;
final int i = NbDocument.findLineNumber((StyledDocument)c.getDocument(), c.getSelectionEnd());
return c.getSelectionStart() == c.getSelectionEnd() || NbDocument.findLineColumn((StyledDocument)c.getDocument(), c.getSelectionEnd()) > 0 ? i + 1 : i;
}
代码示例来源:origin: tinyMediaManager/tinyMediaManager
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
JTextComponent jtc = (JTextComponent) popupMenu.getInvoker();
boolean enableCutCopy = (jtc.getSelectionEnd() - jtc.getSelectionStart()) > 0;
boolean enablePaste = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null) != null;
mntmCut.setEnabled(enableCutCopy);
mntmCopy.setEnabled(enableCutCopy);
mntmPaste.setEnabled(enablePaste);
}
});
代码示例来源:origin: de.sciss/syntaxpane
@Override
public void escapePressed() {
target.setCaretPosition(target.getSelectionEnd());
setVisible(false);
}
}
代码示例来源:origin: de.sciss/syntaxpane
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument sdoc,
int dot, ActionEvent e) {
try {
int st = sdoc.getLineStartOffset(target.getSelectionStart());
int en = sdoc.getLineEndOffset(target.getSelectionEnd());
sdoc.remove(st, en - st);
} catch (BadLocationException ex) {
Logger.getLogger(DeleteLinesAction.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
private boolean isInSelection( int iPosition )
{
if( _owner.getEditor().getSelectionStart() == _owner.getEditor().getSelectionEnd() )
{
return false;
}
return iPosition >= _owner.getEditor().getSelectionStart() &&
iPosition <= _owner.getEditor().getSelectionEnd();
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf
public void defaultAction(JTextComponent component) {
if (component != null) {
// Items with no insert prefix and no custom code template
// are "read-only" (such as the method call items)
if (getInsertPrefix().length() == 0) {
return;
}
Completion.get().hideAll();
int caretOffset = component.getSelectionEnd();
substituteText(component, substitutionOffset, caretOffset - substitutionOffset, null);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript-refactoring
public TextComponentTask(EditorCookie ec) {
this.textC = ec.getOpenedPanes()[0];
this.caret = textC.getCaretPosition();
this.start = textC.getSelectionStart();
this.end = textC.getSelectionEnd();
assert caret != -1;
assert start != -1;
assert end != -1;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf
public void caretUpdate(CaretEvent e) {
FileObject file = OpenedEditors.getFileObject(component);
if (file != null) {
setLastSelection(OpenedEditors.getFileObject(component), component.getSelectionStart(), component.getSelectionEnd());
rescheduleTask.schedule(timeout);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans
@Override
public void defaultAction(JTextComponent component) {
if (component != null) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
int caretOffset = component.getSelectionEnd();
substituteText(component, substitutionOffset, caretOffset - substitutionOffset, null);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public void defaultAction(JTextComponent component) {
if (component != null) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
int caretOffset = component.getSelectionEnd();
substituteText(component, substitutionOffset, caretOffset - substitutionOffset);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public void defaultAction(JTextComponent component) {
if (component != null) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
int caretOffset = component.getSelectionEnd();
substituteText(component, substitutionOffset, caretOffset - substitutionOffset);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public void defaultAction(JTextComponent component) {
if (component != null) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
int caretOffset = component.getSelectionEnd();
substituteText(component, substitutionOffset, caretOffset - substitutionOffset);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public void processKeyEvent(KeyEvent evt) {
if (evt.getID() == KeyEvent.KEY_TYPED) {
JTextComponent component = (JTextComponent) evt.getSource();
int caretOffset = component.getSelectionEnd();
final int len = caretOffset - substitutionOffset;
if (len < 0) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public void processKeyEvent(KeyEvent evt) {
if (evt.getID() == KeyEvent.KEY_TYPED) {
JTextComponent component = (JTextComponent) evt.getSource();
int caretOffset = component.getSelectionEnd();
final int len = caretOffset - substitutionOffset;
if (len < 0) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public void processKeyEvent(KeyEvent evt) {
if (evt.getID() == KeyEvent.KEY_TYPED) {
JTextComponent component = (JTextComponent) evt.getSource();
int caretOffset = component.getSelectionEnd();
final int len = caretOffset - substitutionOffset;
if (len < 0) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
boolean active;
if (mark != null) {
active = mark.activateLayer;
} else {
JTextComponent c = ctx.getEditorUI().getComponent();
active = (c != null) && c.getCaret().isSelectionVisible()
&& ctx.getFragmentOffset() >= c.getSelectionStart()
&& ctx.getFragmentOffset() < c.getSelectionEnd();
}
return active;
}
内容来源于网络,如有侵权,请联系作者删除!