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

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

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

JTextField.getCaret介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public JTextFieldTest() {
  this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
  String s = "It was an Abyssinian maid, and on her dulcimer she played,";
  JTextField tf = new JTextField(s);
  tf.setFont(new Font("Serif", Font.PLAIN, 24));
  tf.validate();
  int h = tf.getPreferredSize().height;
  tf.getCaret().setDot(0);
  this.setPreferredSize(new Dimension(240, h));
  this.add(tf);
}

代码示例来源:origin: stackoverflow.com

in.getCaret().setDot(n);
public void keyPressed(KeyEvent arg0)
  if (in.getCaret().getDot() <= n)

代码示例来源:origin: jcoplien/trygve

@Override public int getSelectionEnd() {
    final Caret caret = super.getCaret();
    if (null == caret) {
      setCaret(new DefaultCaret());
    }
    final int end = null == caret? 0: Math.max(caret.getDot(), caret.getMark());
    return end;
  }
private final static long serialVersionUID = 237718234;

代码示例来源:origin: jcoplien/trygve

@Override public int getSelectionStart() {
   final Caret caret = super.getCaret();
   if (null == caret) {
     setCaret(new DefaultCaret());
   }
   final int start = null == caret? 0: Math.min(caret.getDot(), caret.getMark());
   return start;
 }
 @Override public int getSelectionEnd() {

代码示例来源: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: robo-code/robocode

public void componentShown(ComponentEvent e) {
    String fileName = FileUtil.getRobotsDir().getAbsolutePath() + File.separator;
    File outgoingFile = new File(fileName);
    if (!outgoingFile.exists()) {
      if (!outgoingFile.mkdirs()) {
        Logger.logError("Cannot create: " + outgoingFile);
      }
    }
    String jarName = "myrobots.jar";
    List<IRobotSpecItem> selectedRobots = robotPackager.getRobotSelectionPanel().getSelectedRobots();
    if (selectedRobots != null && selectedRobots.size() == 1) {
      jarName = selectedRobots.get(0).getFullClassName() + "_"
          + robotPackager.getPackagerOptionsPanel().getVersionField().getText() + ".jar";
    }
    getFilenameField().setText(fileName + jarName);
    Caret caret = getFilenameField().getCaret();
    caret.setDot(fileName.length());
    caret.moveDot(fileName.length() + jarName.length() - 4);
    getFilenameField().requestFocus();
  }
}

代码示例来源:origin: org.freehep/freehep-graphicsio-tests

void edit() {
  textField = new JTextField(sourceText);
  textField.setFont(label.getFont());
  textField.setBorder(null);
  textField.setHorizontalAlignment(label.getHorizontalAlignment());
  textField.addActionListener(new ActionListener() {
    public void actionPerformed(final ActionEvent a) {
      finishTextEdit();
    }
  });
  textField.addFocusListener(new FocusAdapter() {
    public void focusLost(final FocusEvent fe) {
      finishTextEdit();
    }
  });
  remove(label);
  add(textField, BorderLayout.CENTER);
  textField.requestFocus();
  revalidate();
  textField.getCaret().setVisible(true);
}

代码示例来源:origin: freehep/freehep-vectorgraphics

void edit() {
  textField = new JTextField(sourceText);
  textField.setFont(label.getFont());
  textField.setBorder(null);
  textField.setHorizontalAlignment(label.getHorizontalAlignment());
  textField.addActionListener(new ActionListener() {
    public void actionPerformed(final ActionEvent a) {
      finishTextEdit();
    }
  });
  textField.addFocusListener(new FocusAdapter() {
    public void focusLost(final FocusEvent fe) {
      finishTextEdit();
    }
  });
  remove(label);
  add(textField, BorderLayout.CENTER);
  textField.requestFocus();
  revalidate();
  textField.getCaret().setVisible(true);
}

代码示例来源:origin: org.jclarion/clarion-runtime

f.selectAll();
} else {
  f.getCaret().setDot(result.length());

代码示例来源:origin: org.jclarion/clarion-runtime

f.getCaret().setDot(f.getText().length());

代码示例来源:origin: org.jclarion/clarion-runtime

f.getCaret().setDot(f.getText().length());

相关文章

JTextField类方法