javax.swing.JTextPane.getSelectionStart()方法的使用及代码示例

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

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

JTextPane.getSelectionStart介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Highlights the sentence that is currently being selected by user
 * (via mouse highlight)
 */
private void highlightSelectedSentence() {
 highlightSentence(textPane.getSelectionStart(), textPane.getSelectionEnd());
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Accessor for text area.
 * This is used by Actions that need ot act on the text area of the View.
 */
public int getSelectionStart() {
  return editor.getSelectionStart();
}

代码示例来源:origin: ron190/jsql-injection

int selectionStart = this.bruteForceManager.getResult().getSelectionStart();
int selectionEnd = this.bruteForceManager.getResult().getSelectionEnd();

代码示例来源:origin: edu.stanford.nlp/stanford-parser

/**
 * Highlights the sentence that is currently being selected by user
 * (via mouse highlight)
 */
private void highlightSelectedSentence() {
 highlightSentence(textPane.getSelectionStart(), textPane.getSelectionEnd());
}

代码示例来源:origin: com.davidbracewell/hermes-core

private void autoExpandSelection() {
 int start = editorPane.getSelectionStart();
 int end = editorPane.getSelectionEnd();
 String txt = editorPane.getText();
 while (start > 0 && !Character.isWhitespace(txt.charAt(start - 1)) && !StringUtils.isPunctuation(
   txt.charAt(start - 1))) {
   start--;
 }
 while (start < end && Character.isWhitespace(txt.charAt(start))) {
   start++;
 }
 while (end < txt.length() && !Character.isWhitespace(txt.charAt(end)) && !StringUtils.isPunctuation(
   txt.charAt(end))) {
   end++;
 }
 while (end > start && Character.isWhitespace(txt.charAt(end - 1))) {
   end--;
 }
 if (start == end) {
   return;
 }
 editorPane.setSelectionEnd(end);
 editorPane.setSelectionStart(start);
}

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

JTextArea jtpSource = parent.getSourcePane();
ExtendedHTMLDocument htmlDoc = parent.getExtendedHtmlDoc();
int selStart = jtpMain.getSelectionStart();
int selEnd = jtpMain.getSelectionEnd();
String[] posStrings = getUniString(2);

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

/**
 * <p>
 * Method for adding a fuzzer in the payloads table.
 * </p>
 */
@Override
public void add() {
  // Check to see what text has been selected
  try {
    requestPane.getSelectedText();
  } catch (final IllegalArgumentException e) {
    JOptionPane
        .showInputDialog(
            this,
            "An exception was thrown while attempting to get the selected text",
            "Add Fuzzer", JOptionPane.ERROR_MESSAGE);
  }
  // Find the location of where the text has been selected
  final int sPoint = requestPane.getSelectionStart();
  final int fPoint = requestPane.getSelectionEnd();
  new PayloadsDialog(this, sPoint, fPoint);
}

代码示例来源:origin: zolyfarkas/spf4j

/**
 * Bundle up the data for export.
 */
@Nullable
protected Transferable createTransferable(JComponent c) {
 javax.swing.JTextPane source = (javax.swing.JTextPane) c;
 int start = source.getSelectionStart();
 int end = source.getSelectionEnd();
 Document doc = source.getDocument();
 if (start == end) {
  return null;
 }
 try {
  p0 = doc.createPosition(start);
  p1 = doc.createPosition(end);
 } catch (BadLocationException e) {
  throw new RuntimeException(e);
 }
 String data = source.getSelectedText();
 return new StringSelection(data);
}

代码示例来源:origin: com.davidbracewell/hermes-core

private void deleteAnnotation() {
 int row = annotationTableModel.find(editorPane.getSelectionStart(), editorPane.getSelectionEnd());
 if (row >= 0) {
   dirty = true;
   deleteAnnotation(new int[]{
    annotationTable.getRowSorter().convertRowIndexToView(row)
   });
 }
}

代码示例来源:origin: otros-systems/otroslogviewer

@Override
 protected void actionPerformedHook(ActionEvent e) {
  String selectedText = logDetailTextArea.getSelectedText();
  if (logDetailTextArea.getSelectionStart() == logDetailTextArea.getSelectionEnd()) {
   selectedText = logDetailTextArea.getText();
  }
  ClipboardUtil.copyToClipboard(selectedText);

 }
}

代码示例来源:origin: com.davidbracewell/hermes-core

@Override
  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
   int start = editorPane.getSelectionStart();
   int end = editorPane.getSelectionEnd();
   if (annotationTableModel.spanHasAnnotation(start, end)) {
     editorPopup.getSubElements()[0].getComponent().setEnabled(true);
     editorPopup.getSubElements()[1].getComponent().setEnabled(false);
   } else {
     editorPopup.getSubElements()[0].getComponent().setEnabled(false);
     editorPopup.getSubElements()[1].getComponent().setEnabled(true);
   }
  }
});

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

public void actionPerformed(ActionEvent e) {
  JTextPane bold = (JTextPane) e.getSource();
  int start = bold.getSelectionStart();
  int end = bold.getSelectionEnd();
  String txt = bold.getSelectedText();

代码示例来源:origin: com.davidbracewell/hermes-core

private void syncEditorSelection(MouseEvent e) {
 if (e.isPopupTrigger()) {
   return;
 }
 int start = editorPane.getSelectionStart();
 int end = editorPane.getSelectionEnd();
 boolean isSelection = (end > start);
 if (!isSelection) {
   end++;
 }
 if (start >= 0) {
   int modelRow = annotationTableModel.find(start, end);
   if (modelRow < 0) {
    return;
   }
   int viewRow = annotationTable.getRowSorter().convertRowIndexToView(modelRow);
   annotationTable.getSelectionModel().setSelectionInterval(viewRow, viewRow);
   editorPane.setSelectionStart(annotationTableModel.getStart(modelRow));
   editorPane.setSelectionEnd(annotationTableModel.getEnd(modelRow));
 }
}

代码示例来源:origin: Wimmics/corese

String line;
String result = "";
int selectedTextSartPosition = current.getTextPaneQuery().getSelectionStart();
int selectedTextEndPosition = current.getTextPaneQuery().getSelectionEnd();
for (int i = 0; i < current.getTextAreaLines().getLineCount() - 1; i++) {

代码示例来源:origin: com.davidbracewell/hermes-core

prevAnnotation.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, KeyEvent.ALT_DOWN_MASK));
prevAnnotation.addActionListener(e -> {
  int start = editorPane.getSelectionStart() - 5;
  int end = editorPane.getSelectionStart();
  Span next = annotationTableModel.annotations.floor(Span.of(start, end));
  System.out.println(next);

代码示例来源:origin: com.davidbracewell/hermes-core

private void addTag(Tag tag) {
 int start = editorPane.getSelectionStart();
 int end = editorPane.getSelectionEnd();
 if (annotationTableModel.spanHasAnnotation(start, end)) {
   if (JOptionPane.showConfirmDialog(null, "Delete existing annotations on span?") == JOptionPane.OK_OPTION) {
    annotationTableModel.annotations.overlapping(new Span(start, end)).forEach(a -> {
      int r = annotationTableModel.find(a.start(), a.end());
      annotationTableModel.removeRow(r);
    });
   } else {
    return;
   }
 }
 if (start == end) {
   return;
 }
 dirty = true;
 editorPane.getStyledDocument()
      .setCharacterAttributes(start, end - start, editorPane.getStyle(tag.name()), true);
 annotationTableModel.addRow(new Object[]{start, end, tag, editorPane.getSelectedText()});
}

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

int caretOffset = parentTextPane.getSelectionStart();
int internalTextLength = selText.length();
String currentAnchor = "";

代码示例来源:origin: com.davidbracewell/hermes-core

return;
if (editorPane.getSelectionStart() == editorPane.getSelectionEnd()) {
 menuBar.getMenu(2).setEnabled(false);
} else {

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

int caretOffset = parentTextPane.getSelectionStart();
int internalTextLength = selText == null ? 0 : selText.length();
if (alignFound) {

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

} else {
 int sOffset = htmlDoc.getParagraphElement(pos).getStartOffset();
 if (sOffset == jtpMain.getSelectionStart()) {
  boolean content = true;
  if (htmlUtilities.checkParentsTag(HTML.Tag.LI)) {

相关文章

JTextPane类方法