本文整理了Java中javax.swing.JTextField.getSelectionEnd()
方法的一些代码示例,展示了JTextField.getSelectionEnd()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.getSelectionEnd()
方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:getSelectionEnd
暂无
代码示例来源:origin: mucommander/mucommander
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == btnCancel) {
dispose();
} else if (source == btnOK) {
range = "[N" + Integer.toString(edtRange.getSelectionStart()+1);
if (edtRange.getSelectionEnd() > 0 && edtRange.getSelectionEnd() > edtRange.getSelectionStart()+1) {
range += "-" + Integer.toString(edtRange.getSelectionEnd());
}
range += "]";
dispose();
}
}
代码示例来源:origin: mucommander/mucommander
/**
* Inserts pattern into pattern edit field.
* @param pattern a text to insert
*/
private void insertPattern(String pattern) {
int pos = edtFileNameMask.getSelectionStart();
try {
int selLen = edtFileNameMask.getSelectionEnd() - edtFileNameMask.getSelectionStart();
if (selLen > 0) {
edtFileNameMask.getDocument().remove(edtFileNameMask.getSelectionStart(), selLen);
}
edtFileNameMask.getDocument().insertString(pos, pattern, null);
} catch (BadLocationException e) {
LOGGER.debug("Caught exception", e);
}
}
代码示例来源:origin: robward-scisys/sldeditor
/**
* Copy text.
*
* <p>Copy all sample text to the system clipboard. Remember the current caret position
* (selection) and restore that afterwards.
*/
public void copyText() {
int end;
int start; // text positions for caret and/or selection
end = selectedCharField.getSelectionEnd(); // remember current position in text
start = selectedCharField.getSelectionStart();
selectedCharField.selectAll(); // select all text in the dialog box
selectedCharField.copy(); // place that text onto the clipboard
selectedCharField.select(start, end); // restore previous caret position
}
代码示例来源:origin: cmu-phil/tetrad
public void focusLost(FocusEvent e) {
JTextField textField = (JTextField) e.getSource();
this.start = textField.getSelectionStart();
this.end = textField.getSelectionEnd();
this.caretPosition = textField.getCaretPosition();
}
}
代码示例来源:origin: org.jclarion/clarion-runtime
@Override
protected void handleRefresh(Object... params) {
getUseObject().setValue(params[0]);
JTextField f=field;
if (f!=null) {
String result = getPicture().format(getUseObject().toString()).trim();
boolean allSelected = f.getSelectionStart()==0 && f.getSelectionEnd()==f.getText().length();
f.setText(result);
try {
if (allSelected) {
f.selectAll();
} else {
f.getCaret().setDot(result.length());
}
} catch (RuntimeException ex) {
}
modified=false;
}
}
代码示例来源:origin: org.jclarion/clarion-runtime
@Override
protected void copy() {
JTextField f = field;
if (f==null) return;
boolean abridged=false;
if (f.getSelectionStart()==0 && f.getSelectionEnd()==f.getText().length()) {
abridged=true;
}
if (f.getSelectionStart()==f.getSelectionEnd()) {
abridged=true;
}
if (abridged) {
ClarionObject o = getUseObject();
if (o!=null) {
String value = o.toString().trim();
if (getPicture()!=null && getPicture().isComputerCoded()) {
value=getPicture().format(value).trim();
}
StringSelection ss = new StringSelection(value);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,ss);
return;
}
}
f.copy();
}
代码示例来源:origin: org.jclarion/clarion-runtime
@Override
public void keyTyped(KeyEvent e) {
if (!e.isConsumed() && e.getKeyChar()!=0 && getPicture().getMaxLen()<=field.getText().length() && field.getSelectionStart()==field.getSelectionEnd()) {
e.consume();
return;
代码示例来源:origin: cmu-phil/tetrad
positionsListener.end = expression.getSelectionEnd();
positionsListener.caretPosition = expression.getCaretPosition();
代码示例来源:origin: org.jclarion/clarion-runtime
if (f!=null) {
String result = getPicture().format(raw_result!=null ? raw_result.toString() : getUseObject().toString()).trim();
boolean allSelected = f.getSelectionStart()==0 && f.getSelectionEnd()==f.getText().length();
f.setText(result);
try {
代码示例来源:origin: org.jclarion/clarion-runtime
@Override
public ClarionObject getAWTProperty(int index)
{
JTextField f = field;
if (f!=null) {
switch (index) {
case Prop.SELSTART:
return new ClarionNumber(f.getSelectionStart() + 1);
case Prop.SELEND:
if (f.getSelectionStart() == f.getSelectionEnd()) {
return new ClarionNumber(0);
}
return new ClarionNumber(f.getSelectionEnd());
case Prop.SCREENTEXT:
return new ClarionString(f.getText());
case Prop.TOUCHED:
return new ClarionNumber(modified ? 1: 0);
}
}
return super.getAWTProperty(index);
}
代码示例来源:origin: org.jclarion/clarion-runtime
@Override
public ClarionObject getAWTProperty(int index)
{
JTextField field=this.field;
if (field!=null) {
switch (index) {
case Prop.SELSTART:
return new ClarionNumber(field.getSelectionStart() + 1);
case Prop.SELEND:
if (field.getSelectionStart() == field.getSelectionEnd()) {
return new ClarionNumber(0);
}
return new ClarionNumber(field.getSelectionEnd());
case Prop.SCREENTEXT:
return new ClarionString(field.getText());
case Prop.TOUCHED:
return new ClarionNumber(modified ? 1: 0);
}
}
return super.getAWTProperty(index);
}
代码示例来源:origin: com.github.waikato/fcms-widgets
text.replace(m_TextSelection.getSelectionStart(), m_TextSelection.getSelectionEnd(), clipboard);
内容来源于网络,如有侵权,请联系作者删除!