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

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

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

JTextField.copy介绍

暂无

代码示例

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@Override
 public void actionPerformed(ActionEvent event) {
  urlTextField.copy();
 }
});

代码示例来源:origin: JetBrains/jediterm

@Override
  public void actionPerformed(final ActionEvent e) {
    if (!(e.getSource() instanceof JComboBox)) return;
    final JComboBox comboBox = (JComboBox) e.getSource();
    final String text;
    final Object selectedItem = comboBox.getSelectedItem();
    if (selectedItem instanceof String) {
      text = (String) selectedItem;
    } else {
      final Component component =
          comboBox.getRenderer().getListCellRendererComponent(new JList(), selectedItem, 0, false, false);
      if (component instanceof JLabel) {
        text = ((JLabel) component).getText();
      } else if (component != null) {
        final String str = component.toString();
        // skip default Component.toString and handle SimpleColoredComponent case
        text = str == null || str.startsWith(component.getClass().getName() + "[") ? null : str;
      } else {
        text = null;
      }
    }
    if (text != null) {
      final JTextField textField = new JTextField(text);
      textField.selectAll();
      textField.copy();
    }
  }
});

代码示例来源: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: 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();
}

相关文章

JTextField类方法