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

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

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

JTextArea.replaceSelection介绍

暂无

代码示例

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

@Override
  public void actionPerformed(ActionEvent e) {
    externalCommandTextArea.replaceSelection(variablesList.getSelectedItem().toString());
  }
});

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

public void actionPerformed(ActionEvent evt) {
    JComboBox cb = (JComboBox) evt.getSource();
    String placeName = (String) cb.getSelectedItem();
    function.replaceSelection(placeName);
  }
});

代码示例来源:origin: com.hermit-reasoner/org.semanticweb.hermit

public void replaceSelection(String string) {
  moveToEndIfNecessary();
  super.replaceSelection(string);
}
protected void processKeyEvent(KeyEvent event) {

代码示例来源:origin: net.sourceforge.owlapi/org.semanticweb.hermit

@Override
public void replaceSelection(String string) {
  moveToEndIfNecessary();
  super.replaceSelection(string);
}
@Override

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

private void initGui() {
  panel = new SaveOptionsPanel();
  panel.insertButton.addActionListener(
      e -> panel.externalCommandTextArea.replaceSelection(panel.variablesList.getSelectedItem().toString()));
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

private void buttonPasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPasteActionPerformed
 try {
  this.editorPane.replaceSelection((String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor));
 } catch (UnsupportedFlavorException ex) {
  // no text data in clipboard
 } catch (IOException ex) {
  LOGGER.error("Error during paste from clipboard", ex); //NOI18N
 }
}//GEN-LAST:event_buttonPasteActionPerformed

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

private void initGui() {
  panel = new TMMatchesPreferencesPanel();
  panel.sortMatchesList.setModel(new DefaultComboBoxModel<>(SORT_KEY.values()));
  panel.sortMatchesList.setRenderer(new DelegatingComboBoxRenderer<SORT_KEY, String>() {
    @Override
    protected String getDisplayText(SORT_KEY value) {
      return OStrings.getString("EXT_TMX_SORT_KEY_" + value.name());
    }
  });
  panel.sortMatchesList.addActionListener(e -> {
    boolean changed = valueIsDifferent(Preferences.EXT_TMX_SORT_KEY, panel.sortMatchesList.getSelectedItem());
    setReloadRequired(changed);
  });
  panel.insertButton
      .addActionListener(
          e -> panel.matchesTemplate.replaceSelection(panel.variablesList.getSelectedItem().toString()));
  panel.variablesList
      .setModel(new DefaultComboBoxModel<>(new Vector<>(MatchesVarExpansion.getMatchesVariables())));
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-editor

while (SearchEngine.find(textArea, toFind, true, matchCase,
          wholeWord, false)) {
  textArea.replaceSelection(replaceWith);
  count++;

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

while (SearchEngine.find(textArea, toFind, true, matchCase,
          wholeWord, false)) {
  textArea.replaceSelection(replaceWith);
  count++;

代码示例来源:origin: com.hermit-reasoner/org.semanticweb.hermit

protected void processKeyEvent(KeyEvent event) {
  if (event.getKeyCode()!=KeyEvent.VK_ENTER)
    super.processKeyEvent(event);
  if (event.getID()==KeyEvent.KEY_PRESSED && event.getKeyCode()==KeyEvent.VK_ENTER) {
    int textEnd=getDocument().getLength();
    select(textEnd,textEnd);
    super.replaceSelection("\n");
    textEnd=getDocument().getLength();
    String text;
    try {
      text=getDocument().getText(m_userTypedTextStart,textEnd-m_userTypedTextStart);
    }
    catch (BadLocationException error) {
      text="";
    }
    m_reader.addToBuffer(text);
    m_userTypedTextStart=textEnd;
    select(m_userTypedTextStart,m_userTypedTextStart);
  }
}

代码示例来源:origin: org.owasp.jbrofuzz/jbrofuzz

/**
   * <p>Write output to the console of the Graphing Panel.</p>
   * 
   * @param input
   */
  public void toConsole(final String input) {

    // Use a FILO for the output to the console, never exceeding 500 lines
    if (console.getLineCount() > 500) {
      try {
        console.select(console.getLineStartOffset(0), console
            .getLineEndOffset(console.getLineCount() - 500));
        console.replaceSelection("...\n");
      } catch (final BadLocationException e) {
        Logger.log("Could not clear the console", 3);
      }
    }

    console.append("> " + input + "\n");
    console.setCaretPosition(console.getText().length());

  }
}

代码示例来源:origin: orbisgis/orbisgis

/**
 * Block comment the selected text in the given script panel.
 *
 * @param scriptPanel Script panel
 */
private static void blockComment(JTextArea scriptPanel) {
  // Recover the index of the start of the selection.
  final int startOffset = scriptPanel.getSelectionStart();
  // Comment the selection.
  final String commentedSelection = BLOCK_COMMENT_START
      + scriptPanel.getSelectedText() + BLOCK_COMMENT_END;
  scriptPanel.replaceSelection(commentedSelection);
  // Select the commented selection.
  scriptPanel.setSelectionStart(startOffset);
  scriptPanel.setSelectionEnd(startOffset + commentedSelection.length());
}

代码示例来源:origin: net.sourceforge.owlapi/org.semanticweb.hermit

@Override
protected void processKeyEvent(KeyEvent event) {
  if (event.getKeyCode()!=KeyEvent.VK_ENTER)
    super.processKeyEvent(event);
  if (event.getID()==KeyEvent.KEY_PRESSED && event.getKeyCode()==KeyEvent.VK_ENTER) {
    int textEnd=getDocument().getLength();
    select(textEnd,textEnd);
    super.replaceSelection("\n");
    textEnd=getDocument().getLength();
    String text;
    try {
      text=getDocument().getText(m_userTypedTextStart,textEnd-m_userTypedTextStart);
    }
    catch (@SuppressWarnings("unused") BadLocationException error) {
      text="";
    }
    m_reader.addToBuffer(text);
    m_userTypedTextStart=textEnd;
    select(m_userTypedTextStart,m_userTypedTextStart);
  }
}

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

textArea.replaceSelection(replaceWith);
return true;

代码示例来源:origin: org.codehaus.jtstand/jtstand-editor

textArea.replaceSelection(replaceWith);
return true;

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial

private void onBrowseRecentMessages() {
  StringSelector.RecentMessageSelector selector = new StringSelector.RecentMessageSelector(HgModuleConfig.getDefault().getPreferences());
  String message = selector.getRecentMessage(getMessage("CTL_CommitForm_RecentTitle"),  // NOI18N
                      getMessage("CTL_CommitForm_RecentPrompt"),  // NOI18N
    Utils.getStringList(HgModuleConfig.getDefault().getPreferences(), CommitAction.RECENT_COMMIT_MESSAGES));
  if (message != null) {
    messageTextArea.replaceSelection(message);
  }
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-editor

textArea.replaceSelection(info.getReplacement());

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

textArea.replaceSelection(info.getReplacement());

相关文章

JTextArea类方法