本文整理了Java中javax.swing.JTextPane.getSelectionEnd()
方法的一些代码示例,展示了JTextPane.getSelectionEnd()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.getSelectionEnd()
方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:getSelectionEnd
暂无
代码示例来源: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 project text area.
*/
public int getSelectionEnd() {
return editor.getSelectionEnd();
}
代码示例来源:origin: ron190/jsql-injection
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
ExtendedHTMLDocument htmlDoc = parent.getExtendedHtmlDoc();
int selStart = jtpMain.getSelectionStart();
int selEnd = jtpMain.getSelectionEnd();
String[] posStrings = getUniString(2);
if(posStrings == null)
代码示例来源: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
iEndSel = textArea.getSelectionEnd();
iStartIndex = root.getElementIndex (iStartSel);
iEndIndex = root.getElementIndex (iEndSel);
iItemNo = root.getElementCount();
iStartIndex = root.getElementIndex (textArea.getSelectionStart());
iEndIndex = root.getElementIndex (textArea.getSelectionEnd());
代码示例来源:origin: stackoverflow.com
JTextPane bold = (JTextPane) e.getSource();
int start = bold.getSelectionStart();
int end = bold.getSelectionEnd();
String txt = bold.getSelectedText();
if(end != start)
代码示例来源: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 result = "";
int selectedTextSartPosition = current.getTextPaneQuery().getSelectionStart();
int selectedTextEndPosition = current.getTextPaneQuery().getSelectionEnd();
for (int i = 0; i < current.getTextAreaLines().getLineCount() - 1; i++) {
try {
代码示例来源:origin: fr.inria.wimmics/kggui
String result = "";
int selectedTextSartPosition = current.getTextPaneQuery().getSelectionStart();
int selectedTextEndPosition = current.getTextPaneQuery().getSelectionEnd();
for (int i = 0; i < current.getTextAreaLines().getLineCount() - 1; i++) {
try {
代码示例来源:origin: com.davidbracewell/hermes-core
nextAnnotation.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, KeyEvent.ALT_DOWN_MASK));
nextAnnotation.addActionListener(e -> {
int start = editorPane.getSelectionEnd();
int end = start + 10;
System.out.println(start + " : " + end);
代码示例来源: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: com.davidbracewell/hermes-core
return;
if (editorPane.getSelectionStart() == editorPane.getSelectionEnd()) {
menuBar.getMenu(2).setEnabled(false);
} else {
内容来源于网络,如有侵权,请联系作者删除!