javax.swing.JEditorPane.setSelectionEnd()方法的使用及代码示例

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

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

JEditorPane.setSelectionEnd介绍

暂无

代码示例

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

public void focusLost(java.awt.event.FocusEvent e) {
    editorPane.setSelectionStart(0);
    editorPane.setSelectionEnd(0);
  }
});

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

public void focusGained(java.awt.event.FocusEvent e) {
  editorPane.setSelectionStart(0);
  editorPane.setSelectionEnd(editorPane.getText().length());
}

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

@Override
 public void focusLost(FocusEvent e) {
  if (myEditorPane == null) return;
  int caretPosition = myEditorPane.getCaretPosition();
  myEditorPane.setSelectionStart(caretPosition);
  myEditorPane.setSelectionEnd(caretPosition);
 }
});

代码示例来源:origin: robo-code/robocode

public void findNext() {
  EditWindow currentWindow = editor.getActiveWindow();
  if (currentWindow == null || getFindTextField().getText().length() == 0) {
    // launch error dialog?
    return;
  }
  Pattern p = getCurrentPattern();
  JEditorPane editorPane = currentWindow.getEditorPane();
  // for some reason, getText() trims off \r but the indexes in
  // the editor pane don't.
  String text = editorPane.getText().replaceAll("\\r", "");
  Matcher m = p.matcher(text);
  int index = editorPane.getSelectionEnd();
  if (!(m.find(index) || m.find())) {
    return;
  }
  editorPane.setSelectionStart(m.start());
  editorPane.setSelectionEnd(m.end());
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-mobility-svgcore

@SuppressWarnings({"deprecation"})
  public void run() {
    EditorCookie ed = svgDoj.getCookie(EditorCookie.class);
    try {
      if (ed != null) {
        ed.openDocument();
        JEditorPane [] opened = ed.getOpenedPanes();
        if ( opened != null && opened.length > 0) {
          final JEditorPane  pane = opened[0];
          pane.setSelectionStart(position);
          pane.setSelectionEnd(position);
          if ( requestFocus) {
            TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass( TopComponent.class, pane);
            if (tc != null) {
              tc.requestActive();
              // the requestActive itself does not work
              tc.requestFocus();
            }
          }
        }
      }            
    } catch( Exception e) {
      SceneManager.error("Select in editor failed.", e); //NOI18N
    }
  }            
});

相关文章

JEditorPane类方法