javax.swing.JTextField.moveCaretPosition()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中javax.swing.JTextField.moveCaretPosition()方法的一些代码示例,展示了JTextField.moveCaretPosition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.moveCaretPosition()方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:moveCaretPosition

JTextField.moveCaretPosition介绍

暂无

代码示例

代码示例来源:origin: org.scijava/ui-behaviour

@Override
  public void run()
  {
    final StringBuffer sb = new StringBuffer( textField.getText() );
    sb.insert( position, completion );
    textField.setText( sb.toString() );
    textField.setCaretPosition( position + completion.length() );
    textField.moveCaretPosition( position );
  }
}

代码示例来源:origin: org.scijava/ui-behaviour

@Override
  public void run()
  {
    final StringBuffer sb = new StringBuffer( textField.getText() );
    sb.insert( position, completion );
    textField.setText( sb.toString() );
    textField.setCaretPosition( position + completion.length() );
    textField.moveCaretPosition( position );
  }
}

代码示例来源:origin: sarahtattersall/PIPE

private void focusGained(JTextField textField) {
  textField.setCaretPosition(0);
  textField.moveCaretPosition(textField.getText().length());
}

代码示例来源:origin: org.jspresso.framework/jspresso-swing-components

/**
  * {@inheritDoc}
  */
 @Override
 public void run() {
  if (!isUsedAsEditor(textField)) {
   // textField.selectAll();
   if (textField.getDocument() != null) {
    textField.setCaretPosition(textField.getDocument().getLength());
    textField.moveCaretPosition(0);
   }
  }
 }
}

代码示例来源:origin: org.jspresso/jspresso-swing-components

/**
  * {@inheritDoc}
  */
 public void run() {
  if (!isUsedAsEditor(textField)) {
   // textField.selectAll();
   if (textField.getDocument() != null) {
    textField.setCaretPosition(textField.getDocument().getLength());
    textField.moveCaretPosition(0);
   }
  }
 }
}

代码示例来源:origin: cmu-phil/tetrad

/**
 * Overrides delegate; sets the value of the textfield to the
 * value of the datum.
 *
 * @param value this value.
 */
public void setValue(Object value) {
  if (value == null) {
    textField.setText(emptyString);
  }
  else if (value instanceof Integer) {
    textField.setText(value.toString());
  }
  else if (value instanceof Double) {
    double doubleValue = (Double) value;
    if (Double.isNaN(doubleValue)) {
      textField.setText(emptyString);
    }
    else {
      textField.setText(nf.format(doubleValue));
    }
  }
  textField.setCaretPosition(0);
  textField.moveCaretPosition(textField.getText().length());
}

代码示例来源:origin: gurkenlabs/litiengine

private void autoComplete() {
 String autoCompletion = this.findAutoCompletion(this.textFieldInput.getText());
 if (autoCompletion == null) {
  return;
 }
 final int currentCaretPosition = this.textFieldInput.getCaretPosition();
 this.textFieldInput.setText(autoCompletion);
 this.validate();
 this.textFieldInput.setCaretPosition(this.textFieldInput.getText().length());
 this.textFieldInput.moveCaretPosition(currentCaretPosition);
}

代码示例来源:origin: cmu-phil/tetrad

nameField.moveCaretPosition(getName().length());

代码示例来源:origin: cmu-phil/tetrad

nameField.moveCaretPosition(getName().length());

代码示例来源:origin: cmu-phil/tetrad

nameField.moveCaretPosition(getName().length());

代码示例来源:origin: cmu-phil/tetrad

nameField.moveCaretPosition(getName().length());

代码示例来源:origin: cmu-phil/tetrad

nameField.moveCaretPosition(getName().length());

代码示例来源:origin: cmu-phil/tetrad

nameField.moveCaretPosition(getName().length());

相关文章

JTextField类方法