本文整理了Java中javax.swing.text.JTextComponent.select()
方法的一些代码示例,展示了JTextComponent.select()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.select()
方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:select
暂无
代码示例来源:origin: deathmarine/Luyten
public void focusLost(FocusEvent e) {
textComponent.select(0, 0);
updateSampleFont();
}
}
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
@Override
protected Transferable createTransferable(JComponent c) {
String text = details.getSelectedText();
if (text == null || text.equals("")) {
details.selectAll();
text = details.getSelectedText();
details.select(-1, -1);
}
return new StringSelection(text);
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
protected Transferable createTransferable(JComponent c) {
String text = details.getSelectedText();
if (text == null || text.equals("")) {
details.selectAll();
text = details.getSelectedText();
details.select(-1, -1);
}
return new StringSelection(text);
}
代码示例来源:origin: runelite/runelite
private void newAutocomplete(KeyEvent e)
{
final JTextComponent input = (JTextComponent)e.getSource();
final String inputText = input.getText();
final String nameStart = inputText.substring(0, input.getSelectionStart()) + e.getKeyChar();
if (findAutocompleteName(nameStart))
{
// Assert this.autocompleteName != null
final String name = this.autocompleteName;
SwingUtilities.invokeLater(() ->
{
try
{
input.getDocument().insertString(
nameStart.length(),
name.substring(nameStart.length()),
null);
input.select(nameStart.length(), name.length());
}
catch (BadLocationException ex)
{
log.warn("Could not autocomplete name.", ex);
}
});
}
}
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
@Override
protected Transferable createTransferable(JComponent c) {
String text = details.getSelectedText();
if (text == null || text.equals("")) {
details.selectAll();
text = details.getSelectedText();
details.select(-1, -1);
}
return new StringSelection(text);
}
代码示例来源:origin: groovy/groovy-core
pos = findNext(false, pos);
if (pos > -1) {
textComponent.select(pos, pos + find.length());
} else {
textComponent.setCaretPosition(last + replace.length());
代码示例来源:origin: org.swinglabs.swingx/swingx-core
@Override
protected Transferable createTransferable(JComponent c) {
String text = details.getSelectedText();
if (text == null || text.equals("")) {
details.selectAll();
text = details.getSelectedText();
details.select(-1, -1);
}
return new StringSelection(text);
}
代码示例来源:origin: groovy/groovy-core
textComponent.select(pos, pos + find.length());
} else {
textComponent.setCaretPosition(last + replace.length());
代码示例来源:origin: org.swinglabs.swingx/swingx-all
@Override
protected Transferable createTransferable(JComponent c) {
String text = details.getSelectedText();
if (text == null || text.equals("")) {
details.selectAll();
text = details.getSelectedText();
details.select(-1, -1);
}
return new StringSelection(text);
}
代码示例来源:origin: runelite/runelite
doc.remove(insertIndex, 1);
doc.insertString(insertIndex, charToInsert, null);
input.select(insertIndex + 1, input.getSelectionEnd());
代码示例来源:origin: groovy/groovy-core
public void actionPerformed(ActionEvent ae) {
lastAction = FIND_ACTION_COMMAND;
findReplaceCount = 0;
if (FIND_REPLACE_DIALOG.isVisible() &&
FIND_REPLACE_DIALOG.getTitle().equals(FIND_ACTION_COMMAND)) {
}
int pos = textComponent.getSelectedText() == null ?
textComponent.getCaretPosition() :
textComponent.getSelectionStart();
boolean reverse = (ae.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
pos = findNext(reverse, pos);
if (pos > -1) {
String pattern = (String) FIND_FIELD.getSelectedItem();
textComponent.select(pos, pos + pattern.length());
findReplaceCount = 1;
}
setListStrings();
fireTextEvent();
}
}
代码示例来源:origin: com.github.haifengl/smile-plot
@Override
public void focusLost(FocusEvent e) {
textComponent.select(0, 0);
updateSampleFont();
}
}
代码示例来源:origin: otros-systems/otroslogviewer
static void clearTextFieldSelectionAsync(final JTextComponent textField) {
SwingUtilities.invokeLater(() -> {
textField.select(0, 0);
final int length = textField.getDocument().getLength();
try {
textField.setCaretPosition(length);
} catch (Exception ignore) {
System.err.println("Can't set caret position to length: " + length);
}
});
}
}
代码示例来源:origin: net.sf.doolin/doolin-gui
@Override
public void focusLost(FocusEvent e) {
this.textComponent.select(0, 0);
updateSampleFont();
}
}
代码示例来源:origin: org.jfree/jcommon
/**
* Deselects the text when a field loses the focus.
*
* @param e the event.
*/
public void focusLost(final FocusEvent e) {
if (e.getSource() instanceof JTextComponent) {
final JTextComponent tex = (JTextComponent) e.getSource();
tex.select(0, 0);
}
}
代码示例来源:origin: jfree/jcommon
/**
* Deselects the text when a field loses the focus.
*
* @param e the event.
*/
public void focusLost(final FocusEvent e) {
if (e.getSource() instanceof JTextComponent) {
final JTextComponent tex = (JTextComponent) e.getSource();
tex.select(0, 0);
}
}
代码示例来源:origin: org.jfree/com.springsource.org.jfree
/**
* Deselects the text when a field loses the focus.
*
* @param e the event.
*/
public void focusLost(final FocusEvent e) {
if (e.getSource() instanceof JTextComponent) {
final JTextComponent tex = (JTextComponent) e.getSource();
tex.select(0, 0);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
private void selectLineForOffset(int y) {
int pos = editor.viewToModel(new Point(0, y));
if (pos >= 0) {
Element root = editor.getDocument().getDefaultRootElement();
Element elem = root.getElement(root.getElementIndex(pos));
if (elem != null) {
int start = elem.getStartOffset();
int end = elem.getEndOffset();
editor.select(start, Math.max(end-1, 0));
}
}
}
}
代码示例来源:origin: de.sciss/jsyntaxpane
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument sDoc,
int dot, ActionEvent e) {
Token t = sDoc.getTokenAt(dot);
if(t != null) {
target.select(t.start, t.end());
}
if (dlg == null) {
dlg = new ReflectCompletionDialog(target);
}
dlg.displayFor(target);
}
}
代码示例来源:origin: de.sciss/syntaxpane
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument sDoc,
int dot, ActionEvent e) {
Token t = sDoc.getTokenAt(dot);
if(t != null) {
target.select(t.start, t.end());
}
if (dlg == null) {
dlg = new ReflectCompletionDialog(target);
}
dlg.displayFor(target);
}
}
内容来源于网络,如有侵权,请联系作者删除!