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

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

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

JTextField.replaceSelection介绍

暂无

代码示例

代码示例来源:origin: org.databene/databene-commons

@Override
public void actionPerformed(ActionEvent e) {
  Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  Transferable t = clipboard.getContents(null);
  if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
    try {
      String data = (String) t.getTransferData(DataFlavor.stringFlavor);
      textField.replaceSelection(data);
    } catch (Exception e1) {
      LOGGER.error("Paste failed", e1);
    }
  }
}

代码示例来源:origin: omegat-org/omegat

private void initGui() {
  panel = new ViewOptionsPanel();
  panel.templateActivator.addActionListener(e -> updateEnabledness());
  panel.viewSourceAllBold.addActionListener(e -> updateEnabledness());
  panel.variablesList
      .setModel(new DefaultComboBoxModel<>(new Vector<>(ModificationInfoManager.getModInfoVariables())));
  panel.variablesListND.setModel(
      new DefaultComboBoxModel<>(new Vector<>(ModificationInfoManager.getModInfoVariablesNoDate())));
  panel.insertButton.addActionListener(
      e -> panel.modInfoTemplate.replaceSelection(panel.variablesList.getSelectedItem().toString()));
  panel.insertButtonND.addActionListener(
      e -> panel.modInfoTemplateND.replaceSelection(panel.variablesListND.getSelectedItem().toString()));
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

public void replaceSelection(String _s) {
 boolean b = true;
 for (int i = 0; i < _s.length(); i++)
  b &= isCharValid(_s.charAt(i));
 if (b) super.replaceSelection(_s);
 else
  getToolkit().beep();
}

相关文章

JTextField类方法